PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.1
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.1
3.7.2 3.7.1 3.7.0 3.6.0 3.6.1 3.5.2 trunk 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.6.1 All 73 releases
stockpack / vendor / guzzlehttp / guzzle / src / Handler / Proxy.php

Proxy.php in StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more 2.1, at vendor/guzzlehttp/guzzle/src/Handler/Proxy.php

56 lines 1.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace GuzzleHttp\Handler;
3
4 use GuzzleHttp\RequestOptions;
5 use Psr\Http\Message\RequestInterface;
6
7 /**
8 * Provides basic proxies for handlers.
9 */
10 class Proxy
11 {
12 /**
13 * Sends synchronous requests to a specific handler while sending all other
14 * requests to another handler.
15 *
16 * @param callable $default Handler used for normal responses
17 * @param callable $sync Handler used for synchronous responses.
18 *
19 * @return callable Returns the composed handler.
20 */
21 public static function wrapSync(
22 callable $default,
23 callable $sync
24 ) {
25 return function (RequestInterface $request, array $options) use ($default, $sync) {
26 return empty($options[RequestOptions::SYNCHRONOUS])
27 ? $default($request, $options)
28 : $sync($request, $options);
29 };
30 }
31
32 /**
33 * Sends streaming requests to a streaming compatible handler while sending
34 * all other requests to a default handler.
35 *
36 * This, for example, could be useful for taking advantage of the
37 * performance benefits of curl while still supporting true streaming
38 * through the StreamHandler.
39 *
40 * @param callable $default Handler used for non-streaming responses
41 * @param callable $streaming Handler used for streaming responses
42 *
43 * @return callable Returns the composed handler.
44 */
45 public static function wrapStreaming(
46 callable $default,
47 callable $streaming
48 ) {
49 return function (RequestInterface $request, array $options) use ($default, $streaming) {
50 return empty($options['stream'])
51 ? $default($request, $options)
52 : $streaming($request, $options);
53 };
54 }
55 }
56