summaryrefslogtreecommitdiff
path: root/lib/httpclient.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2009-09-15 20:40:03 -0400
committerEvan Prodromou <evan@status.net>2009-09-15 21:12:59 -0400
commitae20d073ce8cb393417be6f05cdf54289ecd5bad (patch)
tree290aeb739d22b5042227baad3cca3f98e3fe35c2 /lib/httpclient.php
parent20dd0db7049209a5f43697d8bba8eadb63736bce (diff)
update httpclient class
Diffstat (limited to 'lib/httpclient.php')
-rw-r--r--lib/httpclient.php43
1 files changed, 40 insertions, 3 deletions
diff --git a/lib/httpclient.php b/lib/httpclient.php
index 5c1f4f3e1..145409f50 100644
--- a/lib/httpclient.php
+++ b/lib/httpclient.php
@@ -32,7 +32,7 @@ if (!defined('LACONICA')) {
}
/**
- * Utility class for doing HTTP-related stuff
+ * Useful structure for HTTP responses
*
* We make HTTP calls in several places, and we have several different
* ways of doing them. This class hides the specifics of what underlying
@@ -52,29 +52,66 @@ class HTTPResponse
var $body = null;
}
-class HTTPClientUtil
+/**
+ * Utility class for doing HTTP client stuff
+ *
+ * We make HTTP calls in several places, and we have several different
+ * ways of doing them. This class hides the specifics of what underlying
+ * library (curl or PHP-HTTP or whatever) that's used.
+ *
+ * @category HTTP
+ * @package Laconica
+ * @author Evan Prodromou <evan@controlyourself.ca>
+ * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
+ * @link http://laconi.ca/
+ */
+
+class HTTPClient
{
- function __construct()
+ static $_client = null;
+
+ static function start()
{
+ if (!is_null(self::$_client)) {
+ return self::$_client;
+ }
+
+ $type = common_config('http', 'client');
+
+ switch ($type) {
+ case 'curl':
+ self::$_client = new CurlClient();
+ break;
+ default:
+ throw new Exception("Unknown HTTP client type '$type'");
+ break;
+ }
+
+ return self::$_client;
}
function head($url, $headers)
{
+ throw new Exception("HEAD method unimplemented");
}
function get($url, $headers)
{
+ throw new Exception("GET method unimplemented");
}
function post($url, $headers, $body)
{
+ throw new Exception("POST method unimplemented");
}
function put($url, $headers, $body)
{
+ throw new Exception("PUT method unimplemented");
}
function delete($url, $headers)
{
+ throw new Exception("DELETE method unimplemented");
}
}