diff options
author | Dries Buytaert <dries@buytaert.net> | 2004-06-21 20:14:41 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2004-06-21 20:14:41 +0000 |
commit | 77ec01f59209b46422f32faa55dcb5c4eea03f6a (patch) | |
tree | e346d12f8269ac9e3c2e85812f202a2e9e4f6538 /includes | |
parent | 090743bdbaf4866da57c6c54b03c398477903168 (diff) | |
download | brdo-77ec01f59209b46422f32faa55dcb5c4eea03f6a.tar.gz brdo-77ec01f59209b46422f32faa55dcb5c4eea03f6a.tar.bz2 |
- Patch #8344 by Kjartan: drupal_http_request() did not always handle EOLs
correctly.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/common.inc | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/includes/common.inc b/includes/common.inc index cb3e78d50..f1e4b0a2a 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -361,22 +361,18 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data = fclose($fp); // Parse response. - $response = preg_split("/\r\n|\n|\r/", $response); - list($protocol, $code, $text) = explode(' ', trim(array_shift($response)), 3); + list($headers, $result->data) = explode("\r\n\r\n", $response, 2); + $headers = preg_split("/\r\n|\n|\r/", $headers); + + list($protocol, $code, $text) = explode(' ', trim(array_shift($headers)), 3); $result->headers = array(); - $result->data = ''; // Parse headers. - while ($line = trim(array_shift($response))) { - if ($line == '') { - break; - } + while ($line = trim(array_shift($headers))) { list($header, $value) = explode(':', $line, 2); $result->headers[$header] = trim($value); } - $result->data = implode('', $response); - $responses = array( 100 => 'Continue', 101 => 'Switching Protocols', 200 => 'OK', 201 => 'Created', 202 => 'Accepted', 203 => 'Non-Authoritative Information', 204 => 'No Content', 205 => 'Reset Content', 206 => 'Partial Content', |