diff options
author | Damien Regad <dregad@mantisbt.org> | 2021-02-06 01:19:42 +0100 |
---|---|---|
committer | Damien Regad <dregad@mantisbt.org> | 2021-02-06 01:19:58 +0100 |
commit | 056bf31f718b923ee6b8d13d398d7da9f8cf5512 (patch) | |
tree | 168e55cb8665d56132518db7260d6d43a70d8feb /inc/HTTP/HTTPClient.php | |
parent | 049a05cf604fcd79943558d64942a5c937a47d4d (diff) | |
download | dokuwiki-056bf31f718b923ee6b8d13d398d7da9f8cf5512.tar.gz dokuwiki-056bf31f718b923ee6b8d13d398d7da9f8cf5512.zip |
Fix various errors in PHPUnit tests on PHP 8
Diffstat (limited to 'inc/HTTP/HTTPClient.php')
-rw-r--r-- | inc/HTTP/HTTPClient.php | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/inc/HTTP/HTTPClient.php b/inc/HTTP/HTTPClient.php index 4aaf47168..ea57fa64d 100644 --- a/inc/HTTP/HTTPClient.php +++ b/inc/HTTP/HTTPClient.php @@ -178,10 +178,9 @@ class HTTPClient { // parse URL into bits $uri = parse_url($url); $server = $uri['host']; - $path = $uri['path']; - if(empty($path)) $path = '/'; + $path = !empty($uri['path']) ? $uri['path'] : '/'; + $uriPort = !empty($uri['port']) ? $uri['port'] : null; if(!empty($uri['query'])) $path .= '?'.$uri['query']; - if(!empty($uri['port'])) $port = $uri['port']; if(isset($uri['user'])) $this->user = $uri['user']; if(isset($uri['pass'])) $this->pass = $uri['pass']; @@ -209,8 +208,8 @@ class HTTPClient { // prepare headers $headers = $this->headers; - $headers['Host'] = $uri['host']; - if(!empty($uri['port'])) $headers['Host'].= ':'.$uri['port']; + $headers['Host'] = $uri['host'] + . ($uriPort ? ':' . $uriPort : ''); $headers['User-Agent'] = $this->agent; $headers['Referer'] = $this->referer; @@ -370,10 +369,10 @@ class HTTPClient { // handle non-RFC-compliant relative redirects if (!preg_match('/^http/i', $this->resp_headers['location'])){ if($this->resp_headers['location'][0] != '/'){ - $this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].':'.$uri['port']. - dirname($uri['path']).'/'.$this->resp_headers['location']; + $this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].':'.$uriPort. + dirname($path).'/'.$this->resp_headers['location']; }else{ - $this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].':'.$uri['port']. + $this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].':'.$uriPort. $this->resp_headers['location']; } } @@ -511,7 +510,7 @@ class HTTPClient { if(!$this->useProxyForUrl($requesturl)) return false; $requestinfo = parse_url($requesturl); if($requestinfo['scheme'] != 'https') return false; - if(!$requestinfo['port']) $requestinfo['port'] = 443; + if(empty($requestinfo['port'])) $requestinfo['port'] = 443; // build request $request = "CONNECT {$requestinfo['host']}:{$requestinfo['port']} HTTP/1.0".HTTP_NL; |