summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDries Buytaert2004-06-21 20:15:19 (GMT)
committerDries Buytaert2004-06-21 20:15:19 (GMT)
commitdd13f8dc7244149e98ebb1d626dc064e54656465 (patch)
treee809c30668c5552e9426669e67f591b0c624c9fa
parent8176ad403ca1b90e9cde3d22c56da3b55f0d055b (diff)
- Patch #8344 by Kjartan: drupal_http_request() did not always handle EOLs
correctly.
-rw-r--r--includes/common.inc14
1 files changed, 5 insertions, 9 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 8f6f242..7de4eb6 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -340,22 +340,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',