]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
config['follow_redirects'] is the extlib's config! if max_redirs is set we want to...
authorhannes <h@nnesmannerhe.im>
Mon, 25 Jan 2016 19:03:26 +0000 (19:03 +0000)
committerhannes <h@nnesmannerhe.im>
Mon, 25 Jan 2016 19:03:26 +0000 (19:03 +0000)
lib/httpclient.php

index 31f3ae206c39f8544acfad363b7a30e940713797..bd182f8757384151b45b609290af1ce5651458ad 100644 (file)
@@ -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