diff options
-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); } } |