]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/httpclient.php
Use ToSelector choice again.
[quix0rs-gnu-social.git] / lib / httpclient.php
index 4c7a4a9c6493b3d88f702e6c5508d27a58d2a630..ae2c7b067243c84ddcad9824e1909c7c0464b8a1 100644 (file)
@@ -116,6 +116,7 @@ class HTTPClient extends HTTP_Request2
 
     function __construct($url=null, $method=self::METHOD_GET, $config=array())
     {
+        $this->config['connect_timeout'] = common_config('http', 'connect_timeout') ?: $this->config['connect_timeout'];
         $this->config['max_redirs'] = 10;
         $this->config['follow_redirects'] = true;
         
@@ -320,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();
@@ -332,6 +334,9 @@ 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");
@@ -350,8 +355,6 @@ class HTTPClient extends HTTP_Request2
                     continue;
                 } catch (HTTP_Request2_Exception $e) {
                     common_log(LOG_ERR, __CLASS__ . ": Invalid $code redirect from $url to $target");
-                } catch (NoHttpResponseException $e) {
-                    common_log(LOG_ERR, __CLASS__ . ": {$e->getMessage()}");
                 }
             } else {
                 $reason = $response->getReasonPhrase();