You are here

public static function Proxy::wrapStreaming in Lockr 7.3

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 $default Handler used for non-streaming responses:

callable $streaming Handler used for streaming responses:

Return value

callable Returns the composed handler.

1 call to Proxy::wrapStreaming()
choose_handler in vendor/guzzlehttp/guzzle/src/functions.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\Handler

Code

public static function wrapStreaming(callable $default, callable $streaming) {
  return function (RequestInterface $request, array $options) use ($default, $streaming) {
    return empty($options['stream']) ? $default($request, $options) : $streaming($request, $options);
  };
}