Skip to content

Commit

Permalink
Added CURLOPT_PORT option to HTTP class
Browse files Browse the repository at this point in the history
  • Loading branch information
gadiener authored Sep 5, 2018
1 parent a65c853 commit 55f7413
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions classes/HTTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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) {
Expand Down

0 comments on commit 55f7413

Please sign in to comment.