diff options
author | Andreas Gohr <andi@splitbrain.org> | 2009-09-04 17:22:57 +0200 |
---|---|---|
committer | Andreas Gohr <andi@splitbrain.org> | 2009-09-04 17:22:57 +0200 |
commit | 824defcf4684faaedc08059b8380b7eadd856501 (patch) | |
tree | 4fc83c9ff5d98e683965ee23c864c1c479e035e1 | |
parent | 4c30ec5fb2134dc976404ec4c2e712b1cf501b2e (diff) | |
download | rpg-824defcf4684faaedc08059b8380b7eadd856501.tar.gz rpg-824defcf4684faaedc08059b8380b7eadd856501.tar.bz2 |
Handle relative redirects correctly FS#1741
Ignore-this: a85fdaa1c3aae0315a5f2a51ccbde5a0
Some servers (or scripts) do not send full qualified URLs in the Location
header on redirects.
darcs-hash:20090904152257-7ad00-a9749251c59e4235723ed18bcb9a8f4d3f4157ba.gz
-rw-r--r-- | inc/HTTPClient.php | 10 |
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'); |