From 45cd55bfc4735be4c9b3a1fc31b93ab0b8ad92a8 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Wed, 8 Oct 2014 06:14:58 +0000 Subject: [PATCH] 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 --- src/wp-includes/class-http.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/class-http.php b/src/wp-includes/class-http.php index c8330e09e2..d52bb118fe 100644 --- a/src/wp-includes/class-http.php +++ b/src/wp-includes/class-http.php @@ -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";