- 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']) {
case 'http':
$port = isset($uri['port']) ? $uri['port'] : 80;
$host = $uri['host'] . ($port != 80 ? ':'. $port : '');
$fp = @fsockopen($uri['host'], $port, $errno, $errstr, 15);
break;
case 'https':
// Note: Only works for PHP 4.3 compiled with OpenSSL.
$port = isset($uri['port']) ? $uri['port'] : 443;
$host = $uri['host'] . ($port != 443 ? ':'. $port : '');
$fp = @fsockopen('ssl://'. $uri['host'], $port, $errno, $errstr, 20);
break;
default:
@ -340,8 +342,10 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
// Create HTTP request.
$defaults = array(
// RFC 2616: "non-standard ports MUST, default ports MAY be included". We always add it.
'Host' => "Host: $uri[host]:$port",
// RFC 2616: "non-standard ports MUST, default ports MAY be included".
// 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/)',
'Content-Length' => 'Content-Length: '. strlen($data)
);