Skip to content

Commit

Permalink
Added follow_location functionality to JHttpTransportSocket
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-cz committed Sep 6, 2014
1 parent 9fae264 commit ef9fd98
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion libraries/joomla/http/transport/socket.php
Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit ef9fd98

Please sign in to comment.