From 63dd9b84ff341ba71d37f47ccf403a8bf488c4d6 Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 9 Sep 2016 16:47:59 +1000 Subject: [PATCH 1/2] Only include the port in the `Host` header when it differs from default --- library/Requests/Transport/fsockopen.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Requests/Transport/fsockopen.php b/library/Requests/Transport/fsockopen.php index e9170f417..86c564f69 100644 --- a/library/Requests/Transport/fsockopen.php +++ b/library/Requests/Transport/fsockopen.php @@ -171,7 +171,7 @@ public function request($url, $headers = array(), $data = array(), $options = ar if (!isset($case_insensitive_headers['Host'])) { $out .= sprintf('Host: %s', $url_parts['host']); - if ($url_parts['port'] !== 80) { + if (( 'http' === $url_parts['scheme'] && $url_parts['port'] !== 80 ) || ( 'https' === $url_parts['scheme'] && $url_parts['port'] !== 443 )) { $out .= ':' . $url_parts['port']; } $out .= "\r\n"; From 9b402cbfa28f718307ca7c8a3f5ad7a71b0ac1fe Mon Sep 17 00:00:00 2001 From: Dion Hulse Date: Fri, 9 Sep 2016 16:50:11 +1000 Subject: [PATCH 2/2] Case insensitive comparison for the `scheme` element. --- library/Requests/Transport/fsockopen.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/Requests/Transport/fsockopen.php b/library/Requests/Transport/fsockopen.php index 86c564f69..cad61b5cc 100644 --- a/library/Requests/Transport/fsockopen.php +++ b/library/Requests/Transport/fsockopen.php @@ -171,7 +171,7 @@ public function request($url, $headers = array(), $data = array(), $options = ar if (!isset($case_insensitive_headers['Host'])) { $out .= sprintf('Host: %s', $url_parts['host']); - if (( 'http' === $url_parts['scheme'] && $url_parts['port'] !== 80 ) || ( 'https' === $url_parts['scheme'] && $url_parts['port'] !== 443 )) { + if (( 'http' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 80 ) || ( 'https' === strtolower($url_parts['scheme']) && $url_parts['port'] !== 443 )) { $out .= ':' . $url_parts['port']; } $out .= "\r\n";