When making a HTTP request to a non-standard port, include the port in the Host header for the Streams HTTP transport. This bring parity to the cURL transport and respects the HTTP RFC.

Props kamelkev for the initial patch; Fixes #28982


git-svn-id: https://develop.svn.wordpress.org/trunk@29852 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Dion Hulse
2014-10-08 06:14:58 +00:00
parent 4ae1397f96
commit 45cd55bfc4

View File

@@ -970,10 +970,17 @@ class WP_Http_Streams {
$strHeaders = strtoupper($r['method']) . ' ' . $requestPath . ' HTTP/' . $r['httpversion'] . "\r\n";
if ( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) )
$include_port_in_host_header = (
( $proxy->is_enabled() && $proxy->send_through_proxy( $url ) ) ||
( 'http' == $arrURL['scheme'] && 80 != $arrURL['port'] ) ||
( 'https' == $arrURL['scheme'] && 443 != $arrURL['port'] )
);
if ( $include_port_in_host_header ) {
$strHeaders .= 'Host: ' . $arrURL['host'] . ':' . $arrURL['port'] . "\r\n";
else
} else {
$strHeaders .= 'Host: ' . $arrURL['host'] . "\r\n";
}
if ( isset($r['user-agent']) )
$strHeaders .= 'User-agent: ' . $r['user-agent'] . "\r\n";