Commit 34792fa8 authored by Dries's avatar Dries

- Patch #303838 by c960657, Aron Novak: drupal_http_request() - case sensitive...

- Patch #303838 by c960657, Aron Novak: drupal_http_request() - case sensitive HTTP header field names.
parent 8c60927b
......@@ -758,7 +758,9 @@ function drupal_access_denied() {
* - error
* If an error occurred, the error message. Otherwise not set.
* - headers
* An array containing the response headers as name/value pairs.
* An array containing the response headers as name/value pairs. HTTP
* header names are case-insensitive (RFC 2616, section 4.2), so for easy
* access the array keys are returned in lower case.
* - data
* A string containing the response body that was received.
*/
......@@ -917,14 +919,15 @@ function drupal_http_request($url, array $options = array()) {
// Parse the response headers.
while ($line = trim(array_shift($response))) {
list($header, $value) = explode(':', $line, 2);
if (isset($result->headers[$header]) && $header == 'Set-Cookie') {
list($name, $value) = explode(':', $line, 2);
$name = strtolower($name);
if (isset($result->headers[$name]) && $name == 'set-cookie') {
// RFC 2109: the Set-Cookie response header comprises the token Set-
// Cookie:, followed by a comma-separated list of one or more cookies.
$result->headers[$header] .= ',' . trim($value);
$result->headers[$name] .= ',' . trim($value);
}
else {
$result->headers[$header] = trim($value);
$result->headers[$name] = trim($value);
}
}
......@@ -984,7 +987,7 @@ function drupal_http_request($url, array $options = array()) {
case 301: // Moved permanently
case 302: // Moved temporarily
case 307: // Moved temporarily
$location = $result->headers['Location'];
$location = $result->headers['location'];
$options['timeout'] -= timer_read(__FUNCTION__) / 1000;
if ($options['timeout'] <= 0) {
$result->code = HTTP_REQUEST_TIMEOUT;
......
......@@ -24,7 +24,7 @@ function aggregator_aggregator_parse($feed) {
// Filter the input data.
if (aggregator_parse_feed($feed->source_string, $feed)) {
$modified = empty($feed->http_headers['Last-Modified']) ? 0 : strtotime($feed->http_headers['Last-Modified']);
$modified = empty($feed->http_headers['last-modified']) ? 0 : strtotime($feed->http_headers['last-modified']);
// Prepare the channel data.
foreach ($channel as $key => $value) {
......@@ -43,7 +43,7 @@ function aggregator_aggregator_parse($feed) {
$image = '';
}
$etag = empty($feed->http_headers['ETag']) ? '' : $feed->http_headers['ETag'];
$etag = empty($feed->http_headers['etag']) ? '' : $feed->http_headers['etag'];
// Add parsed data to the feed object.
$feed->link = !empty($channel['LINK']) ? $channel['LINK'] : '';
......
......@@ -437,14 +437,14 @@ function _openid_xrds_discovery($claimed_id) {
$result = drupal_http_request($xrds_url, array('headers' => $headers));
if (!isset($result->error)) {
if (isset($result->headers['Content-Type']) && preg_match("/application\/xrds\+xml/", $result->headers['Content-Type'])) {
if (isset($result->headers['content-type']) && preg_match("/application\/xrds\+xml/", $result->headers['content-type'])) {
// Parse XML document to find URL
$services = _openid_xrds_parse($result->data);
}
else {
$xrds_url = NULL;
if (isset($result->headers['X-XRDS-Location'])) {
$xrds_url = $result->headers['X-XRDS-Location'];
if (isset($result->headers['x-xrds-location'])) {
$xrds_url = $result->headers['x-xrds-location'];
}
else {
// Look for meta http-equiv link in HTML head
......
......@@ -110,7 +110,8 @@ function system_test_basic_auth_page() {
function system_test_redirect($code) {
$code = (int) $code;
if ($code != 200) {
header("Location: " . url('system-test/redirect/200', array('absolute' => TRUE)), TRUE, $code);
// Header names are case-insensitive.
header("locaTION: " . url('system-test/redirect/200', array('absolute' => TRUE)), TRUE, $code);
exit;
}
return '';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment