private function CurlFactory::createHeaderFn in Lockr 7.3
1 call to CurlFactory::createHeaderFn()
- CurlFactory::create in vendor/
guzzlehttp/ guzzle/ src/ Handler/ CurlFactory.php - Creates a cURL handle resource.
File
- vendor/
guzzlehttp/ guzzle/ src/ Handler/ CurlFactory.php, line 525
Class
- CurlFactory
- Creates curl resources from a request
Namespace
GuzzleHttp\HandlerCode
private function createHeaderFn(EasyHandle $easy) {
if (isset($easy->options['on_headers'])) {
$onHeaders = $easy->options['on_headers'];
if (!is_callable($onHeaders)) {
throw new \InvalidArgumentException('on_headers must be callable');
}
}
else {
$onHeaders = null;
}
return function ($ch, $h) use ($onHeaders, $easy, &$startingResponse) {
$value = trim($h);
if ($value === '') {
$startingResponse = true;
$easy
->createResponse();
if ($onHeaders !== null) {
try {
$onHeaders($easy->response);
} catch (\Exception $e) {
// Associate the exception with the handle and trigger
// a curl header write error by returning 0.
$easy->onHeadersException = $e;
return -1;
}
}
}
elseif ($startingResponse) {
$startingResponse = false;
$easy->headers = [
$value,
];
}
else {
$easy->headers[] = $value;
}
return strlen($h);
};
}