X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fhttpclient.php;h=c251a03d4551e0ef0a209050b691793a8771ad85;hb=89dd44bf3e6b5774497d7fdcd56d0ebc5cc87ffa;hp=bc513e71d03359b893a95b75cb044b98ab332a7e;hpb=b7edac26106833382c65d90570a2eea7def5faab;p=quix0rs-gnu-social.git diff --git a/lib/httpclient.php b/lib/httpclient.php index bc513e71d0..c251a03d45 100644 --- a/lib/httpclient.php +++ b/lib/httpclient.php @@ -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. *