diff --git a/httpclient.php b/httpclient.php index 807a72d..1f9c3db 100644 --- a/httpclient.php +++ b/httpclient.php @@ -309,8 +309,17 @@ class Httpclient if ($this->redirectCount > $this->redirectMaxCount) throw new \Exception ("Redirect exceed maximum limit", 406); // echo "REDIRECT TO ".$this->headersReceived["Location"]."\n"; - $content = $this->getPage ($this->headersReceived["Location"], - $ssloptions); + $location = $this->headersReceived["Location"]; + $parseURLInit = parse_url ($url); + $parseURLLocation = parse_url ($location); + if (! key_exists ("port", $parseURLLocation) && + key_exists ("port", $parseURLInit)) + $location = ":".$parseURLInit["port"].$location; + if (! key_exists ("host", $parseURLLocation)) + $location = $parseURLInit["host"].$location; + if (! key_exists ("scheme", $parseURLLocation)) + $location = $parseURLInit["scheme"]."://".$location; + $content = $this->getPage ($location, $ssloptions); } $this->redirectCount = 0; return $content;