From 4234b51c2a1b551cc1eed8be68eac0ea1666b29b Mon Sep 17 00:00:00 2001 From: git <git@43475.no-reply.drupal.org> Date: Thu, 29 Dec 2011 13:14:28 -0500 Subject: [PATCH] Issue #1380636 by gnucifer, emackn: Fixed Wrong response headers reported on 3xx requests in function http_request_get(). --- libraries/http_request.inc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libraries/http_request.inc b/libraries/http_request.inc index 85e578ec..e4009995 100644 --- a/libraries/http_request.inc +++ b/libraries/http_request.inc @@ -172,14 +172,15 @@ function http_request_get($url, $username = NULL, $password = NULL, $accept_inva )), curl_errno($download) ); } + $header_size = curl_getinfo($download, CURLINFO_HEADER_SIZE); $header = substr($data, 0, $header_size - 1); - $result->data = substr($data, $header_size); - $header_lines = preg_split("/\r\n|\n|\r/", $header); - + $headers = preg_split("/(\r\n){2}/", $header); + $header_lines = preg_split("/\r\n|\n|\r/", end($headers)); $result->headers = array(); array_shift($header_lines); // skip HTTP response status + while ($line = trim(array_shift($header_lines))) { list($header, $value) = explode(':', $line, 2); // Normalize the headers. -- GitLab