This code:
$headersSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
$responseHeaders = substr($response, 0, $headersSize);
$responseBody = substr($response, $headersSize);
return incorrect size (strlen) of headers, e.g. here:
...
Pragma: no-cache
Set-Cookie: foo=bar; pat
---- curl want split here ----
h=/
Access-Control-Allow-Origin: *
<!DOCTYPE html ...
Response can have multiple headers (redirections, continue, etc.). And ofcourse like this isnt work:
list($header, $body) = explode("\r\n\r\n", $response, 2);
How to correct determine size of headers?
That fix was commit bc6037e which went into curl 7.30.0