From: hannes Date: Mon, 25 Jan 2016 19:03:26 +0000 (+0000) Subject: config['follow_redirects'] is the extlib's config! if max_redirs is set we want to... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=b1b6a0a69cfc2a4b178ba07c10120cac750919fa;p=quix0rs-gnu-social.git config['follow_redirects'] is the extlib's config! if max_redirs is set we want to do our own redirection following in this function --- 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