From 786540beef093df0eae43a8d481c03f9adcc58dc Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Sat, 22 Dec 2018 20:22:38 +0000 Subject: [PATCH] httpclient : if the redirect URL is not an absolute one, create the absolute one based on the previous request git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@4796 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- httpclient.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) 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;