]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - lib/httpclient.php
default connect_timeout to 5 instead of extlib 10
[quix0rs-gnu-social.git] / lib / httpclient.php
index bc513e71d03359b893a95b75cb044b98ab332a7e..c251a03d4551e0ef0a209050b691793a8771ad85 100644 (file)
@@ -80,7 +80,7 @@ class GNUsocial_HTTPResponse extends HTTP_Request2_Response
      */
     function getUrl()
     {
-        return $this->url;
+        return $this->effectiveUrl;
     }
 
     /**
@@ -121,6 +121,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;
         
@@ -200,6 +201,16 @@ class HTTPClient extends HTTP_Request2
         return $response->getBody();
     }
 
+    public static function quickGetJson($url, $params=array())
+    {
+        $data = json_decode(self::quickGet($url, null, $params));
+        if (is_null($data)) {
+            common_debug('Could not decode JSON data from URL: '.$url);
+            throw new ServerException('Could not decode JSON data from URL');
+        }
+        return $data;
+    }
+
     /**
      * Convenience function to run a GET request.
      *