Added a quickGet in HTTPClient
This commit is contained in:
parent
3a0136fe1f
commit
5c7ad2e031
|
@ -170,6 +170,21 @@ class HTTPClient extends HTTP_Request2
|
||||||
return new HTTPClient();
|
return new HTTPClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Quick static function to GET a URL
|
||||||
|
*/
|
||||||
|
public static function quickGet($url, $accept='text/html,application/xhtml+xml')
|
||||||
|
{
|
||||||
|
$client = new HTTPClient();
|
||||||
|
$client->setHeader('Accept', $accept);
|
||||||
|
$response = $client->get($url);
|
||||||
|
if (!$response->isOk()) {
|
||||||
|
// TRANS: Exception. %s is a profile URL.
|
||||||
|
throw new Exception(sprintf(_m('Could not GET URL %s.'), $url), $response->getStatus());
|
||||||
|
}
|
||||||
|
return $response->getBody();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convenience function to run a GET request.
|
* Convenience function to run a GET request.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in New Issue
Block a user