You are here

function choose_handler in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/guzzlehttp/guzzle/src/functions.php \GuzzleHttp\choose_handler()

Chooses and creates a default handler to use based on the environment.

The returned handler is not wrapped by any default middlewares.

Return value

callable Returns the best handler for the given system.

Throws

\RuntimeException if no viable Handler is available.

1 call to choose_handler()
HandlerStack::create in vendor/guzzlehttp/guzzle/src/HandlerStack.php
Creates a default handler stack that can be used by clients.

File

vendor/guzzlehttp/guzzle/src/functions.php, line 104

Namespace

GuzzleHttp

Code

function choose_handler() {
  $handler = null;
  if (extension_loaded('curl')) {
    $handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler());
  }
  if (ini_get('allow_url_fopen')) {
    $handler = $handler ? Proxy::wrapStreaming($handler, new StreamHandler()) : new StreamHandler();
  }
  elseif (!$handler) {
    throw new \RuntimeException('GuzzleHttp requires cURL, the ' . 'allow_url_fopen ini setting, or a custom HTTP handler.');
  }
  return $handler;
}