From 55f741334bbb629a46113e44a2fe86f32d6d6cfb Mon Sep 17 00:00:00 2001 From: Gabriele Date: Wed, 5 Sep 2018 15:59:36 +0200 Subject: [PATCH] Added CURLOPT_PORT option to HTTP class --- classes/HTTP.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/classes/HTTP.php b/classes/HTTP.php index 6385919..d60c311 100644 --- a/classes/HTTP.php +++ b/classes/HTTP.php @@ -22,6 +22,8 @@ class HTTP { $proxy = null; // host:port protected static function request($method, $url, $data=[], array $headers=[], $data_as_json=false, $username=null, $password = null){ + preg_match('/.+(?::([0-9]+))\/?/i', $url, $match); + $port = count($match) > 1 ? $match[1] : 80; $http_method = strtoupper($method); $ch = curl_init($url); $opt = [ @@ -36,6 +38,7 @@ protected static function request($method, $url, $data=[], array $headers=[], $d CURLOPT_FOLLOWLOCATION => true, CURLOPT_ENCODING => '', CURLOPT_PROXY => static::$proxy, + CURLOPT_PORT => $port ]; if($username && $password) {