GuzzleHttpHandlerProxy

Provides basic proxies for handlers.

Defined (1)

The class is defined in the following location(s).

/lib/Azure/GuzzleHttp/Handler/Proxy.php  
  1. class Proxy 
  2. /** 
  3. * Sends synchronous requests to a specific handler while sending all other 
  4. * requests to another handler. 
  5. * @param callable $default Handler used for normal responses 
  6. * @param callable $sync Handler used for synchronous responses. 
  7. * @return callable Returns the composed handler. 
  8. */ 
  9. public static function wrapSync( 
  10. callable $default,  
  11. callable $sync 
  12. ) { 
  13. return function (RequestInterface $request, array $options) use ($default, $sync) { 
  14. return empty($options[RequestOptions::SYNCHRONOUS]) 
  15. ? $default($request, $options) 
  16. : $sync($request, $options); 
  17. }; 
  18.  
  19. /** 
  20. * Sends streaming requests to a streaming compatible handler while sending 
  21. * all other requests to a default handler. 
  22. * This, for example, could be useful for taking advantage of the 
  23. * performance benefits of curl while still supporting true streaming 
  24. * through the StreamHandler. 
  25. * @param callable $default Handler used for non-streaming responses 
  26. * @param callable $streaming Handler used for streaming responses 
  27. * @return callable Returns the composed handler. 
  28. */ 
  29. public static function wrapStreaming( 
  30. callable $default,  
  31. callable $streaming 
  32. ) { 
  33. return function (RequestInterface $request, array $options) use ($default, $streaming) { 
  34. return empty($options['stream']) 
  35. ? $default($request, $options) 
  36. : $streaming($request, $options); 
  37. };