diff options
author | Matthieu Aubry <mattab@users.noreply.github.com> | 2017-09-20 14:02:48 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-20 14:02:48 +0300 |
commit | e4750236c6668b9126271cc6eef02256a64ec9f0 (patch) | |
tree | 2020b521ec738402a0c522c081a10f4ef56ddbdb | |
parent | 3689b2ae2a262d2d86df5ea7c1d0e9ceda287ea7 (diff) |
Use Piwik.org in our HTTP Socket integration test (#12074)
* Use Piwik.org in our HTTP Socket integration test
* use exact "piwik.org" in HTTP socket integration test
* use "ssl://" if necessary for HTTP socket
* divert from spec to please HTTP socket test
-rw-r--r-- | core/Http.php | 8 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/HttpTest.php | 2 |
2 files changed, 7 insertions, 3 deletions
diff --git a/core/Http.php b/core/Http.php index 3ad1b2ce39..59628852ab 100644 --- a/core/Http.php +++ b/core/Http.php @@ -213,7 +213,7 @@ class Http throw new Exception('Invalid protocol/scheme: ' . $url['scheme']); } $host = $url['host']; - $port = isset($url['port']) ? $url['port'] : 80; + $port = isset($url['port']) ? $url['port'] : ('https' == $url['scheme'] ? 443 : 80); $path = isset($url['path']) ? $url['path'] : '/'; if (isset($url['query'])) { $path .= '?' . $url['query']; @@ -241,6 +241,10 @@ class Http $connectHost = $host; $connectPort = $port; $requestHeader = "$httpMethod $path HTTP/$httpVer\r\n"; + + if ('https' == $url['scheme']) { + $connectHost = 'ssl://' . $connectHost; + } } // connection attempt @@ -258,7 +262,7 @@ class Http // send HTTP request header $requestHeader .= - "Host: $host" . ($port != 80 ? ':' . $port : '') . "\r\n" + "Host: $host" . ($port != 80 && ('https' == $url['scheme'] && $port != 443) ? ':' . $port : '') . "\r\n" . ($httpAuth ? $httpAuth : '') . ($proxyAuth ? $proxyAuth : '') . 'User-Agent: ' . $userAgent . "\r\n" diff --git a/tests/PHPUnit/Integration/HttpTest.php b/tests/PHPUnit/Integration/HttpTest.php index 29a0d71161..db4e370862 100644 --- a/tests/PHPUnit/Integration/HttpTest.php +++ b/tests/PHPUnit/Integration/HttpTest.php @@ -289,7 +289,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testSocketHttpsWorksWithValidCertificate() { - $result = Http::sendHttpRequestBy('socket', 'https://www.google.com/', 10); + $result = Http::sendHttpRequestBy('socket', 'https://piwik.org/', 10); $this->assertNotEmpty($result); } } |