From f84caaa069c18223cb24e7c2c681ffa8d21c7a8b Mon Sep 17 00:00:00 2001 From: Piotr Konieczny Date: Mon, 19 May 2014 14:30:45 +0200 Subject: [PATCH 1/3] Added follow_location functionality to JHttpTransportSocket --- libraries/joomla/http/transport/socket.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libraries/joomla/http/transport/socket.php b/libraries/joomla/http/transport/socket.php index f32a520b0ae49..e3441cb9c1c4a 100644 --- a/libraries/joomla/http/transport/socket.php +++ b/libraries/joomla/http/transport/socket.php @@ -142,7 +142,20 @@ public function request($method, JUri $uri, $data = null, array $headers = null, $content .= fgets($connection, 4096); } - return $this->getResponse($content); + $content = $this->getResponse($content); + + /* Wikipedia says: A user agent should not automatically redirect a request more than five times, + * since such redirections usually indicate an infinite loop + * + * However JHttpTransportCurl doesn't set CURLOPT_MAXREDIRS, JHttpTransportStream uses max_redirects default 20 + * so let's rely on severs' sanity :D + */ + if ($content->code >= 301 && $content->code < 400 && isset($content->headers['Location'])) + { + return $this->request($method, new JUri($content->headers['Location']), $data, $headers, $timeout, $userAgent); + } + + return $content; } /** From 884b30042c55a5fcc937e4c8fe489d86ffb09c3b Mon Sep 17 00:00:00 2001 From: Piotr Konieczny Date: Mon, 19 May 2014 14:31:09 +0200 Subject: [PATCH 2/3] Keep alphabetical order of detected transports across all environments --- libraries/joomla/http/factory.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libraries/joomla/http/factory.php b/libraries/joomla/http/factory.php index 3dead789e293d..d410b544e32c5 100644 --- a/libraries/joomla/http/factory.php +++ b/libraries/joomla/http/factory.php @@ -120,6 +120,9 @@ public static function getHttpTransports() } } + // Keep alphabetical order across all environments + sort($names); + return $names; } } From a8f37b4bc0fd396a24b57bd9eec029e142458444 Mon Sep 17 00:00:00 2001 From: Piotr Konieczny Date: Mon, 19 May 2014 15:03:05 +0200 Subject: [PATCH 3/3] Shortened description --- libraries/joomla/http/transport/socket.php | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libraries/joomla/http/transport/socket.php b/libraries/joomla/http/transport/socket.php index e3441cb9c1c4a..3538eb4eee9d6 100644 --- a/libraries/joomla/http/transport/socket.php +++ b/libraries/joomla/http/transport/socket.php @@ -144,12 +144,7 @@ public function request($method, JUri $uri, $data = null, array $headers = null, $content = $this->getResponse($content); - /* Wikipedia says: A user agent should not automatically redirect a request more than five times, - * since such redirections usually indicate an infinite loop - * - * However JHttpTransportCurl doesn't set CURLOPT_MAXREDIRS, JHttpTransportStream uses max_redirects default 20 - * so let's rely on severs' sanity :D - */ + // Follow Http redirects if ($content->code >= 301 && $content->code < 400 && isset($content->headers['Location'])) { return $this->request($method, new JUri($content->headers['Location']), $data, $headers, $timeout, $userAgent); @@ -321,5 +316,4 @@ public static function isSupported() { return function_exists('fsockopen') && is_callable('fsockopen'); } - }