summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/common.inc9
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)
);