summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/HTTPClient.php10
1 files changed, 8 insertions, 2 deletions
diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php
index 4dee28b9e..77b227e06 100644
--- a/inc/HTTPClient.php
+++ b/inc/HTTPClient.php
@@ -343,9 +343,15 @@ class HTTPClient {
}else{
$this->redirect_count++;
$this->referer = $url;
+ // handle non-RFC-compliant relative redirects
if (!preg_match('/^http/i', $this->resp_headers['location'])){
- $this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].
- $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'];
+ }else{
+ $this->resp_headers['location'] = $uri['scheme'].'://'.$uri['host'].':'.$uri['port'].
+ $this->resp_headers['location'];
+ }
}
// perform redirected request, always via GET (required by RFC)
return $this->sendRequest($this->resp_headers['location'],array(),'GET');