From b1b6a0a69cfc2a4b178ba07c10120cac750919fa Mon Sep 17 00:00:00 2001 From: hannes Date: Mon, 25 Jan 2016 19:03:26 +0000 Subject: [PATCH] config['follow_redirects'] is the extlib's config! if max_redirs is set we want to do our own redirection following in this function --- lib/httpclient.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/httpclient.php b/lib/httpclient.php index 31f3ae206c..bd182f8757 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -321,10 +321,11 @@ class HTTPClient extends HTTP_Request2 public function send() { $maxRedirs = intval($this->config['max_redirs']); - if (empty($this->config['follow_redirects'])) { + if (empty($this->config['max_redirs'])) { $maxRedirs = 0; } $redirs = 0; + $redirUrls = array(); do { try { $response = parent::send(); @@ -333,9 +334,12 @@ class HTTPClient extends HTTP_Request2 throw $e; } $code = $response->getStatus(); + $effectiveUrl = $response->getEffectiveUrl(); + $redirUrls[] = $effectiveUrl; + $response->redirUrls = $redirUrls; if ($code >= 200 && $code < 300) { $reason = $response->getReasonPhrase(); - $this->log(LOG_INFO, "$code $reason"); + $this->log(LOG_INFO, "$code $reason - Effective URL: ".$response->getEffectiveUrl().' – redirect: '.json_encode($response->isRedirect())); } elseif ($code >= 300 && $code < 400) { $url = $this->getUrl(); $target = $response->getHeader('Location'); @@ -362,4 +366,4 @@ class HTTPClient extends HTTP_Request2 } while ($maxRedirs); return new GNUsocial_HTTPResponse($response, $this->getUrl(), $redirs); } -} +} \ No newline at end of file