diff --git a/common/HttpClient.php b/common/HttpClient.php index abfb6a8..f5f4bda 100644 --- a/common/HttpClient.php +++ b/common/HttpClient.php @@ -25,6 +25,8 @@ class HttpClient private $ssl_cert_file = ''; private $ssl_key_file = ''; + private $port = 80; + const POST = 'post'; const GET = 'get'; const PUT = 'put'; @@ -171,6 +173,13 @@ class HttpClient public function setIsSSL(bool $isSSL) { $this->isSSL = $isSSL; + $this->port = 443; + } + + + public function setPort($port) + { + $this->port = $port; } /** @@ -239,6 +248,9 @@ class HttpClient $explode = explode('/', $url); $first = array_shift($explode); if (preg_match('/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/', $first)) { + if (strpos($first, ':') !== false) { + [$first, $this->port] = explode(':', $first); + } return $first; } return System::gethostbyname($first); @@ -306,6 +318,9 @@ class HttpClient */ private function getHostPort() { + if (!empty($this->port)) { + return $this->port; + } $port = 80; if ($this->isSSL) $port = 443; return $port;