function Proxy::wrapStreaming
Sends streaming requests to a streaming compatible handler while sending all other requests to a default handler.
This, for example, could be useful for taking advantage of the performance benefits of curl while still supporting true streaming through the StreamHandler.
Parameters
callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface $default Handler used for non-streaming responses:
callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface $streaming Handler used for streaming responses:
Return value
callable(\Psr\Http\Message\RequestInterface, array): \GuzzleHttp\Promise\PromiseInterface Returns the composed handler.
1 call to Proxy::wrapStreaming()
- Utils::chooseHandler in vendor/
guzzlehttp/ guzzle/ src/ Utils.php - Chooses and creates a default handler to use based on the environment.
File
-
vendor/
guzzlehttp/ guzzle/ src/ Handler/ Proxy.php, line 45
Class
- Proxy
- Provides basic proxies for handlers.
Namespace
GuzzleHttp\HandlerCode
public static function wrapStreaming(callable $default, callable $streaming) : callable {
return static function (RequestInterface $request, array $options) use ($default, $streaming) : PromiseInterface {
return empty($options['stream']) ? $default($request, $options) : $streaming($request, $options);
};
}