function choose_handler in Lockr 7.3
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 103
Namespace
GuzzleHttpCode
function choose_handler() {
$handler = null;
if (function_exists('curl_multi_exec') && function_exists('curl_exec')) {
$handler = Proxy::wrapSync(new CurlMultiHandler(), new CurlHandler());
}
elseif (function_exists('curl_exec')) {
$handler = new CurlHandler();
}
elseif (function_exists('curl_multi_exec')) {
$handler = new CurlMultiHandler();
}
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;
}