- Patch #49129 by markus: remove port from HTTP requests.

4.7.x
Dries Buytaert 2006-02-16 13:00:18 +00:00
parent eaa10cd724
commit ae470d6943
1 changed files with 6 additions and 2 deletions

View File

@ -314,11 +314,13 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
switch ($uri['scheme']) { switch ($uri['scheme']) {
case 'http': case 'http':
$port = isset($uri['port']) ? $uri['port'] : 80; $port = isset($uri['port']) ? $uri['port'] : 80;
$host = $uri['host'] . ($port != 80 ? ':'. $port : '');
$fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15); $fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
break; break;
case 'https': case 'https':
// Note: Only works for PHP 4.3 compiled with OpenSSL. // Note: Only works for PHP 4.3 compiled with OpenSSL.
$port = isset($uri['port']) ? $uri['port'] : 443; $port = isset($uri['port']) ? $uri['port'] : 443;
$host = $uri['host'] . ($port != 443 ? ':'. $port : '');
$fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20); $fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
break; break;
default: default:
@ -340,8 +342,10 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
// Create HTTP request. // Create HTTP request.
$defaults = array( $defaults = array(
// RFC 2616: "non-standard ports MUST, default ports MAY be included". We always add it. // RFC 2616: "non-standard ports MUST, default ports MAY be included".
'Host' => "Host: $uri[host]:$port", // We don't add the port to prevent from breaking rewrite rules checking
// the host that do not take into account the port number.
'Host' => "Host: $host",
'User-Agent' => 'User-Agent: Drupal (+http://www.drupal.org/)', 'User-Agent' => 'User-Agent: Drupal (+http://www.drupal.org/)',
'Content-Length' => 'Content-Length: '. strlen($data) 'Content-Length' => 'Content-Length: '. strlen($data)
); );