3 * StatusNet, the distributed open-source microblogging tool
5 * Utility for doing HTTP-related things
9 * LICENCE: This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU Affero General Public License as published by
11 * the Free Software Foundation, either version 3 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Affero General Public License for more details.
19 * You should have received a copy of the GNU Affero General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
24 * @author Evan Prodromou <evan@status.net>
25 * @copyright 2009 StatusNet, Inc.
26 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
27 * @link http://status.net/
30 if (!defined('STATUSNET')) {
35 * Useful structure for HTTP responses
37 * We make HTTP calls in several places, and we have several different
38 * ways of doing them. This class hides the specifics of what underlying
39 * library (curl or PHP-HTTP or whatever) that's used.
43 * @author Evan Prodromou <evan@status.net>
44 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
45 * @link http://status.net/
51 public $headers = null;
56 * Utility class for doing HTTP client stuff
58 * We make HTTP calls in several places, and we have several different
59 * ways of doing them. This class hides the specifics of what underlying
60 * library (curl or PHP-HTTP or whatever) that's used.
64 * @author Evan Prodromou <evan@status.net>
65 * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0
66 * @link http://status.net/
71 static $_client = null;
73 static function start()
75 if (!is_null(self::$_client)) {
76 return self::$_client;
79 $type = common_config('http', 'client');
83 self::$_client = new CurlClient();
86 throw new Exception("Unknown HTTP client type '$type'");
90 return self::$_client;
93 function head($url, $headers)
95 throw new Exception("HEAD method unimplemented");
98 function get($url, $headers)
100 throw new Exception("GET method unimplemented");
103 function post($url, $headers, $body)
105 throw new Exception("POST method unimplemented");
108 function put($url, $headers, $body)
110 throw new Exception("PUT method unimplemented");
113 function delete($url, $headers)
115 throw new Exception("DELETE method unimplemented");
120 return "StatusNet/".STATUSNET_VERSION." (".STATUSNET_CODENAME.")";