diff options
author | Dries Buytaert <dries@buytaert.net> | 2005-09-29 12:33:34 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2005-09-29 12:33:34 +0000 |
commit | bf08ab83b621a7db54f5ff63e1a0765f986a852c (patch) | |
tree | 64f2fcb32faf07308c864e9d8ee48a0166984a9a | |
parent | 1d94bb4a874da85ca3316a8815785a06c9ba4c95 (diff) | |
download | brdo-bf08ab83b621a7db54f5ff63e1a0765f986a852c.tar.gz brdo-bf08ab83b621a7db54f5ff63e1a0765f986a852c.tar.bz2 |
- Patch #32440 by ax: drupal_http_request() doesn't send proper Host: header.
-rw-r--r-- | includes/common.inc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/includes/common.inc b/includes/common.inc index 244e2e803..5911933dd 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -332,11 +332,13 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data = $uri = parse_url($url); switch ($uri['scheme']) { case 'http': - $fp = @fsockopen($uri['host'], ($uri['port'] ? $uri['port'] : 80), $errno, $errstr, 15); + $port = $uri['port'] ? $uri['port'] : 80; + $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15); break; case 'https': // Note: Only works for PHP 4.3 compiled with OpenSSL. - $fp = @fsockopen('ssl://'. $uri['host'], ($uri['port'] ? $uri['port'] : 443), $errno, $errstr, 20); + $port = $uri['port'] ? $uri['port'] : 443; + $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20); break; default: $result->error = 'invalid schema '. $uri['scheme']; @@ -357,7 +359,8 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data = // Create HTTP request. $defaults = array( - 'Host' => 'Host: '. $uri['host'], + // RFC 2616: "non-standard ports MUST, default ports MAY be included". We always add it. + 'Host' => "Host: $uri[host]:$port", 'User-Agent' => 'User-Agent: Drupal (+http://www.drupal.org/)', 'Content-Length' => 'Content-Length: '. strlen($data) ); |