Split response into headers and body based on the size of the headers cURL reports.

Fixes an issue with 100 Continue status codes, etc. where r\n\r\n appears within the list of headers.
This commit is contained in:
PJ Dietz 2013-08-14 10:47:02 -04:00
parent 8268daedfb
commit dbd4ff96a5
1 changed files with 3 additions and 1 deletions

View File

@ -362,7 +362,9 @@ class Request extends Message implements RequestInterface
$resp->statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $resp->statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Split the result into headers and body. // Split the result into headers and body.
list ($headers, $body) = explode("\r\n\r\n", $result, 2); $headerSize = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
$headers = substr($result, 0, $headerSize);
$body = substr($result, $headerSize);
// Set the body. Do not auto-add the Content-length header. // Set the body. Do not auto-add the Content-length header.
$resp->setBody($body, false); $resp->setBody($body, false);