From 258ede7c54e605174c9ff7976039b607f6707b36 Mon Sep 17 00:00:00 2001 From: Chuck Hagenbuch Date: Fri, 4 Sep 2009 11:40:48 -0400 Subject: [PATCH] Initial refactoring to split backends based on request/response objects --- .../examples/Horde/Http}/get-example-dot-com.php | 6 +- .../lib/Horde/Http/Client.php | 63 +++++++----------- .../Client => Http/lib/Horde/Http}/Exception.php | 6 +- .../lib/Horde/Http/Request/Base.php} | 32 +++++++-- .../lib/Horde/Http/Request}/Curl.php | 22 +++---- .../lib/Horde/Http/Request}/Fopen.php | 30 ++++----- .../lib/Horde/Http/Request}/Mock.php | 24 +++---- .../lib/Horde/Http/Request}/Peclhttp.php | 27 ++++---- .../lib/Horde/Http/Response/Base.php} | 8 +-- framework/Http/lib/Horde/Http/Response/Curl.php | 0 framework/Http/lib/Horde/Http/Response/Fopen.php | 0 .../Http/lib/Horde/Http/Response/Peclhttp.php | 0 framework/Http/package.xml | 70 ++++++++++++++++++++ .../Client => Http/test/Horde/Http}/AllTests.php | 14 ++-- .../Adapter => Http/test/Horde/Http}/FopenTest.php | 12 ++-- .../lib/Horde/Http/Client/Adapter/Base.php | 74 --------------------- framework/Http_Client/package.xml | 75 ---------------------- 17 files changed, 188 insertions(+), 275 deletions(-) rename framework/{Http_Client/examples/Horde/Http/Client => Http/examples/Horde/Http}/get-example-dot-com.php (73%) rename framework/{Http_Client => Http}/lib/Horde/Http/Client.php (73%) rename framework/{Http_Client/lib/Horde/Http/Client => Http/lib/Horde/Http}/Exception.php (89%) rename framework/{Http_Client/lib/Horde/Http/Client/Request.php => Http/lib/Horde/Http/Request/Base.php} (82%) rename framework/{Http_Client/lib/Horde/Http/Client/Adapter => Http/lib/Horde/Http/Request}/Curl.php (53%) rename framework/{Http_Client/lib/Horde/Http/Client/Adapter => Http/lib/Horde/Http/Request}/Fopen.php (71%) rename framework/{Http_Client/lib/Horde/Http/Client => Http/lib/Horde/Http/Request}/Mock.php (64%) rename framework/{Http_Client/lib/Horde/Http/Client/Adapter => Http/lib/Horde/Http/Request}/Peclhttp.php (54%) rename framework/{Http_Client/lib/Horde/Http/Client/Response.php => Http/lib/Horde/Http/Response/Base.php} (95%) create mode 100644 framework/Http/lib/Horde/Http/Response/Curl.php create mode 100644 framework/Http/lib/Horde/Http/Response/Fopen.php create mode 100644 framework/Http/lib/Horde/Http/Response/Peclhttp.php create mode 100644 framework/Http/package.xml rename framework/{Http_Client/test/Horde/Http/Client => Http/test/Horde/Http}/AllTests.php (81%) rename framework/{Http_Client/test/Horde/Http/Client/Adapter => Http/test/Horde/Http}/FopenTest.php (66%) delete mode 100644 framework/Http_Client/lib/Horde/Http/Client/Adapter/Base.php delete mode 100644 framework/Http_Client/package.xml diff --git a/framework/Http_Client/examples/Horde/Http/Client/get-example-dot-com.php b/framework/Http/examples/Horde/Http/get-example-dot-com.php similarity index 73% rename from framework/Http_Client/examples/Horde/Http/Client/get-example-dot-com.php rename to framework/Http/examples/Horde/Http/get-example-dot-com.php index 1b55e2a7a..96f45155f 100644 --- a/framework/Http_Client/examples/Horde/Http/Client/get-example-dot-com.php +++ b/framework/Http/examples/Horde/Http/get-example-dot-com.php @@ -7,12 +7,10 @@ * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ -require 'Horde/Http/Client.php'; -require 'Horde/Http/Client/Exception.php'; -require 'Horde/Http/Client/Response.php'; +require 'Horde/Autoloader.php'; $client = new Horde_Http_Client(); $response = $client->get('http://www.example.com/'); diff --git a/framework/Http_Client/lib/Horde/Http/Client.php b/framework/Http/lib/Horde/Http/Client.php similarity index 73% rename from framework/Http_Client/lib/Horde/Http/Client.php rename to framework/Http/lib/Horde/Http/Client.php index 0e64cdb41..dea2a2f09 100644 --- a/framework/Http_Client/lib/Horde/Http/Client.php +++ b/framework/Http/lib/Horde/Http/Client.php @@ -5,38 +5,32 @@ * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ /** * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ class Horde_Http_Client { /** - * HTTP Adapter to use for transport - * @var Horde_Http_Client_Adapter - */ - protected $_adapter; - - /** * The current HTTP request - * @var Horde_Http_Client_Request + * @var Horde_Http_Request_Base */ protected $_request; /** * The previous HTTP request - * @var Horde_Http_Client_Request + * @var Horde_Http_Request_Base */ protected $_lastRequest; /** * The most recent HTTP response - * @var Horde_Http_Client_Response + * @var Horde_Http_Response_Base */ protected $_lastResponse; @@ -45,11 +39,10 @@ class Horde_Http_Client * * @param array $args Any Http_Client settings to initialize in the * constructor. Available settings are: - * adapter - * adapter.proxyServer - * adapter.proxyUser - * adapter.proxyPass - * adapter.timeout + * client.proxyServer + * client.proxyUser + * client.proxyPass + * client.timeout * request * request.uri * request.headers @@ -58,20 +51,12 @@ class Horde_Http_Client */ public function __construct($args = array()) { - // Set or create adapter object - if (isset($args['adapter'])) { - $this->_adapter = $args['adapter']; - unset($args['adapter']); - } else { - $this->_adapter = $this->_createBestAvailableAdapter(); - } - // Set or create request object if (isset($args['request'])) { $this->_request = $args['request']; unset($args['request']); } else { - $this->_request = new Horde_Http_Client_Request(); + $this->_request = $this->_createBestAvailableRequest(); } foreach ($args as $key => $val) { @@ -83,7 +68,7 @@ class Horde_Http_Client /** * Send a GET request * - * @return Horde_Http_Client_Response + * @return Horde_Http_Response_Base */ public function get($uri = null, $headers = array()) { @@ -93,7 +78,7 @@ class Horde_Http_Client /** * Send a POST request * - * @return Horde_Http_Client_Response + * @return Horde_Http_Response_Base */ public function post($uri = null, $data = null, $headers = array()) { @@ -103,7 +88,7 @@ class Horde_Http_Client /** * Send a PUT request * - * @return Horde_Http_Client_Response + * @return Horde_Http_Response_Base */ public function put($uri = null, $data = null, $headers = array()) { @@ -114,7 +99,7 @@ class Horde_Http_Client /** * Send a DELETE request * - * @return Horde_Http_Client_Response + * @return Horde_Http_Response_Base */ public function delete($uri = null, $headers = array()) { @@ -144,7 +129,7 @@ class Horde_Http_Client * be combined with $this->_headers, and override * headers of the same name for this request only. * - * @return Horde_Http_Client_Response + * @return Horde_Http_Response_Base */ public function request($method, $uri = null, $data = null, $headers = array()) { @@ -189,20 +174,20 @@ class Horde_Http_Client } /** - * Find the best available adapter + * Find the best available request backend * - * @return Horde_Http_Client_Adapter + * @return Horde_Http_Request_Base */ - public function _createBestAvailableAdapter() + public function _createBestAvailableRequest() { - /*if (class_exists('HttpRequest', false)) { - return new Horde_Http_Client_Adapter_Peclhttp(); - } else*/if (extension_loaded('curl')) { - return new Horde_Http_Client_Adapter_Curl(); + if (class_exists('HttpRequest', false)) { + return new Horde_Http_Request_Peclhttp(); + } elseif (extension_loaded('curl')) { + return new Horde_Http_Request_Curl(); } elseif (ini_get('allow_url_fopen')) { - return new Horde_Http_Client_Adapter_Fopen(); + return new Horde_Http_Request_Fopen(); } else { - throw new Horde_Http_Client_Exception('No HTTP adapters are available. You must install pecl_http, curl, or enable allow_url_fopen.'); + throw new Horde_Http_Exception('No HTTP request backends are available. You must install pecl_http, curl, or enable allow_url_fopen.'); } } } diff --git a/framework/Http_Client/lib/Horde/Http/Client/Exception.php b/framework/Http/lib/Horde/Http/Exception.php similarity index 89% rename from framework/Http_Client/lib/Horde/Http/Client/Exception.php rename to framework/Http/lib/Horde/Http/Exception.php index b191463f5..d4a6df037 100644 --- a/framework/Http_Client/lib/Horde/Http/Client/Exception.php +++ b/framework/Http/lib/Horde/Http/Exception.php @@ -5,16 +5,16 @@ * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ /** * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ -class Horde_Http_Client_Exception extends Exception +class Horde_Http_Exception extends Exception { /** * Constructor diff --git a/framework/Http_Client/lib/Horde/Http/Client/Request.php b/framework/Http/lib/Horde/Http/Request/Base.php similarity index 82% rename from framework/Http_Client/lib/Horde/Http/Client/Request.php rename to framework/Http/lib/Horde/Http/Request/Base.php index b5f699a34..b566524ca 100644 --- a/framework/Http_Client/lib/Horde/Http/Client/Request.php +++ b/framework/Http/lib/Horde/Http/Request/Base.php @@ -5,16 +5,16 @@ * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ /** * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ -class Horde_Http_Client_Request +abstract class Horde_Http_Request_Base { /** * URI @@ -42,6 +42,30 @@ class Horde_Http_Client_Request protected $_data; /** + * Proxy server + * @var string + */ + protected $_proxyServer = null; + + /** + * Proxy username + * @var string + */ + protected $_proxyUser = null; + + /** + * Proxy password + * @var string + */ + protected $_proxyPass = null; + + /** + * HTTP timeout + * @var float + */ + protected $_timeout = 5; + + /** * Constructor */ public function __construct($args = array()) @@ -52,7 +76,7 @@ class Horde_Http_Client_Request } /** - * Get a request parameter + * Get an adapter parameter * * @param string $name The parameter to get. * @return mixed Parameter value. diff --git a/framework/Http_Client/lib/Horde/Http/Client/Adapter/Curl.php b/framework/Http/lib/Horde/Http/Request/Curl.php similarity index 53% rename from framework/Http_Client/lib/Horde/Http/Client/Adapter/Curl.php rename to framework/Http/lib/Horde/Http/Request/Curl.php index 1fc720c43..c13d7796f 100644 --- a/framework/Http_Client/lib/Horde/Http/Client/Adapter/Curl.php +++ b/framework/Http/lib/Horde/Http/Request/Curl.php @@ -5,40 +5,38 @@ * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ /** * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ -class Horde_Http_Client_Adapter_Curl extends Horde_Http_Client_Adapter_Base +class Horde_Http_Request_Curl extends Horde_Http_Request_Base { public function __construct() { if (!extension_loaded('curl')) { - throw new Horde_Http_Client_Exception('The curl extension is not installed. See http://php.net/curl.installation'); + throw new Horde_Http_Exception('The curl extension is not installed. See http://php.net/curl.installation'); } } /** - * Send an HTTP request + * Send this HTTP request * - * @param Horde_Http_Client_Request HTTP Request object - * - * @return Horde_Http_Client_Response + * @return Horde_Http_Response_Base */ - public function send($request) + public function send() { $body = tmpfile(); $headers = tmpfile(); $curl = curl_init(); - curl_setopt($curl, CURLOPT_URL, $request->uri); + curl_setopt($curl, CURLOPT_URL, $this->uri); curl_setopt($curl, CURLOPT_FILE, $body); - curl_setopt($curl, CURLOPT_POSTFIELDS, $request->data); + curl_setopt($curl, CURLOPT_POSTFIELDS, $this->data); curl_setopt($curl, CURLOPT_WRITEHEADER, $headers); $result = curl_exec($curl); @@ -46,6 +44,6 @@ class Horde_Http_Client_Adapter_Curl extends Horde_Http_Client_Adapter_Base rewind($body); rewind($headers); - return new Horde_Http_Client_Response($request->uri, $body, stream_get_contents($headers)); + return new Horde_Http_Response_Curl($this->uri, $body, stream_get_contents($headers)); } } diff --git a/framework/Http_Client/lib/Horde/Http/Client/Adapter/Fopen.php b/framework/Http/lib/Horde/Http/Request/Fopen.php similarity index 71% rename from framework/Http_Client/lib/Horde/Http/Client/Adapter/Fopen.php rename to framework/Http/lib/Horde/Http/Request/Fopen.php index a735e9373..06febb722 100644 --- a/framework/Http_Client/lib/Horde/Http/Client/Adapter/Fopen.php +++ b/framework/Http/lib/Horde/Http/Request/Fopen.php @@ -5,37 +5,35 @@ * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ /** * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ -class Horde_Http_Client_Adapter_Fopen extends Horde_Http_Client_Adapter_Base +class Horde_Http_Request_Fopen extends Horde_Http_Request_Base { public function __construct() { if (!ini_get('allow_url_fopen')) { - throw new Horde_Http_Client_Exception('allow_url_fopen must be enabled'); + throw new Horde_Http_Exception('allow_url_fopen must be enabled'); } } /** - * Send an HTTP request + * Send this HTTP request * - * @param Horde_Http_Client_Request HTTP Request object - * - * @return Horde_Http_Client_Response + * @return Horde_Http_Response_Base */ - public function send($request) + public function send() { - $method = $request->method; - $uri = $request->uri; - $headers = $request->headers; - $data = $request->data; + $method = $this->method; + $uri = $this->uri; + $headers = $this->headers; + $data = $this->data; if (is_array($data)) { $data = http_build_query($data, '', '&'); } @@ -69,16 +67,16 @@ class Horde_Http_Client_Adapter_Fopen extends Horde_Http_Client_Adapter_Base $error = error_get_last(); if (preg_match('/HTTP\/(\d+\.\d+) (\d{3}) (.*)$/', $error['message'], $matches)) { // Create a Response for the HTTP error code - return new Horde_Http_Client_Response($uri, null, $matches[0]); + return new Horde_Http_Response_Fopen($uri, null, $matches[0]); } else { - throw new Horde_Http_Client_Exception('Problem with ' . $uri . ': ', $error); + throw new Horde_Http_Exception('Problem with ' . $uri . ': ', $error); } } $meta = stream_get_meta_data($stream); $headers = isset($meta['wrapper_data']) ? $meta['wrapper_data'] : array(); - return new Horde_Http_Client_Response($uri, $stream, $headers); + return new Horde_Http_Response_Fopen($uri, $stream, $headers); } } diff --git a/framework/Http_Client/lib/Horde/Http/Client/Mock.php b/framework/Http/lib/Horde/Http/Request/Mock.php similarity index 64% rename from framework/Http_Client/lib/Horde/Http/Client/Mock.php rename to framework/Http/lib/Horde/Http/Request/Mock.php index 1f7f57a34..e247046c3 100644 --- a/framework/Http_Client/lib/Horde/Http/Client/Mock.php +++ b/framework/Http/lib/Horde/Http/Request/Mock.php @@ -5,16 +5,16 @@ * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ /** * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ -class Horde_Http_Client_Mock extends Horde_Http_Client +class Horde_Http_Request_Mock extends Horde_Http_Request_Base { /** * Array of mock responses @@ -29,21 +29,13 @@ class Horde_Http_Client_Mock extends Horde_Http_Client protected $_responseIndex = 0; /** - * Send an HTTP request + * Send this HTTP request * - * @param string $method HTTP request method (GET, PUT, etc.) - * @param string $uri URI to request, if different from $this->uri - * @param mixed $data Request data. Can be an array of form data that will be - * encoded automatically, or a raw string. - * @param array $headers Any headers specific to this request. They will - * be combined with $this->_headers, and override - * headers of the same name for this request only. + * @return Horde_Http_Response_Base * - * @return Horde_Http_Client_Response - * - * @TODO make lastRequest work somehow. + * @TODO make lastRequest work somehow - not sure if this is still an issue. */ - public function request($method, $uri = null, $data = null, $headers = array()) + public function send() { if ($this->_responseIndex >= count($this->_responses)) { $this->_responseIndex = 0; @@ -54,7 +46,7 @@ class Horde_Http_Client_Mock extends Horde_Http_Client /** * Set the HTTP response(s) to be returned by this adapter * - * @param Horde_Http_Client_Response $response + * @param Horde_Http_Response_Base $response */ public function setResponse($response) { diff --git a/framework/Http_Client/lib/Horde/Http/Client/Adapter/Peclhttp.php b/framework/Http/lib/Horde/Http/Request/Peclhttp.php similarity index 54% rename from framework/Http_Client/lib/Horde/Http/Client/Adapter/Peclhttp.php rename to framework/Http/lib/Horde/Http/Request/Peclhttp.php index ad13739ed..5547e5aa7 100644 --- a/framework/Http_Client/lib/Horde/Http/Client/Adapter/Peclhttp.php +++ b/framework/Http/lib/Horde/Http/Request/Peclhttp.php @@ -5,16 +5,16 @@ * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ /** * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ -class Horde_Http_Client_Adapter_Peclhttp extends Horde_Http_Client_Adapter_Base +class Horde_Http_Request_Peclhttp extends Horde_Http_Request_Base { public static $methods = array( 'GET' => HTTP_METH_GET, @@ -27,23 +27,21 @@ class Horde_Http_Client_Adapter_Peclhttp extends Horde_Http_Client_Adapter_Base public function __construct() { if (!class_exists('HttpRequest', false)) { - throw new Horde_Http_Client_Exception('The pecl_http extension is not installed. See http://php.net/http.install'); + throw new Horde_Http_Exception('The pecl_http extension is not installed. See http://php.net/http.install'); } } /** - * Send an HTTP request + * Send this HTTP request * - * @param Horde_Http_Client_Request HTTP Request object - * - * @return Horde_Http_Client_Response + * @return Horde_Http_Response_Base */ - public function send($request) + public function send() { - $httpRequest = new HttpRequest($request->uri, self::$methods[$request->method]); - $httpRequest->setHeaders($request->headers); + $httpRequest = new HttpRequest($this->uri, self::$methods[$this->method]); + $httpRequest->setHeaders($this->headers); - $data = $request->data; + $data = $this->data; if (is_array($data)) { $httpRequest->setPostFields($data); } else { @@ -53,10 +51,9 @@ class Horde_Http_Client_Adapter_Peclhttp extends Horde_Http_Client_Adapter_Base try { $httpResponse = $httpRequest->send(); } catch (HttpException $e) { - throw new Horde_Http_Client_Exception($e->getMessage(), $e->getCode(), $e); + throw new Horde_Http_Exception($e->getMessage(), $e->getCode(), $e); } - /*@TODO build Horde_Http_Client_Response from $httpResponse */ - return $httpResponse; + return new Horde_Http_Response_Peclhttp($httpResponse); } } diff --git a/framework/Http_Client/lib/Horde/Http/Client/Response.php b/framework/Http/lib/Horde/Http/Response/Base.php similarity index 95% rename from framework/Http_Client/lib/Horde/Http/Client/Response.php rename to framework/Http/lib/Horde/Http/Response/Base.php index e158e422e..1826d4fbe 100644 --- a/framework/Http_Client/lib/Horde/Http/Client/Response.php +++ b/framework/Http/lib/Horde/Http/Response/Base.php @@ -5,16 +5,16 @@ * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ /** * @author Chuck Hagenbuch * @license http://opensource.org/licenses/bsd-license.php BSD * @category Horde - * @package Horde_Http_Client + * @package Horde_Http */ -class Horde_Http_Client_Response +class Horde_Http_Response_Base { /** * Fetched URI @@ -121,7 +121,7 @@ class Horde_Http_Client_Response { $content = @stream_get_contents($this->_stream); if ($content === false) { - throw new Horde_Http_Client_Exception('Problem reading data from ' . $this->uri . ': ' . $php_errormsg); + throw new Horde_Http_Exception('Problem reading data from ' . $this->uri . ': ' . $php_errormsg); } return $content; } diff --git a/framework/Http/lib/Horde/Http/Response/Curl.php b/framework/Http/lib/Horde/Http/Response/Curl.php new file mode 100644 index 000000000..e69de29bb diff --git a/framework/Http/lib/Horde/Http/Response/Fopen.php b/framework/Http/lib/Horde/Http/Response/Fopen.php new file mode 100644 index 000000000..e69de29bb diff --git a/framework/Http/lib/Horde/Http/Response/Peclhttp.php b/framework/Http/lib/Horde/Http/Response/Peclhttp.php new file mode 100644 index 000000000..e69de29bb diff --git a/framework/Http/package.xml b/framework/Http/package.xml new file mode 100644 index 000000000..42fe6224c --- /dev/null +++ b/framework/Http/package.xml @@ -0,0 +1,70 @@ + + + Http + pear.horde.org + Horde HTTP libraries + This package provides a set of classes for making HTTP requests. + + + Chuck Hagenbuch + chuck + chuck@horde.org + yes + + 2009-09-04 + + 0.5.0 + 0.5.0 + + + beta + beta + + BSD + * Refactor to support multiple request transports, including Curl and the PECL http extension. + + + + + + + + + + + + + + + + + + + + + + + + + 5.2.0 + + + 1.5.0 + + + + + + + + + + + + + + + diff --git a/framework/Http_Client/test/Horde/Http/Client/AllTests.php b/framework/Http/test/Horde/Http/AllTests.php similarity index 81% rename from framework/Http_Client/test/Horde/Http/Client/AllTests.php rename to framework/Http/test/Horde/Http/AllTests.php index f2bc7e3bd..a49c7b815 100644 --- a/framework/Http_Client/test/Horde/Http/Client/AllTests.php +++ b/framework/Http/test/Horde/Http/AllTests.php @@ -1,20 +1,20 @@ addTestSuite('Horde_Http_Client_' . $class); + $suite->addTestSuite('Horde_Http_' . $class); } } @@ -49,6 +49,6 @@ class Horde_Http_Client_AllTests { } -if (PHPUnit_MAIN_METHOD == 'Horde_Http_Client_AllTests::main') { - Horde_Http_Client_AllTests::main(); +if (PHPUnit_MAIN_METHOD == 'Horde_Http_AllTests::main') { + Horde_Http_AllTests::main(); } diff --git a/framework/Http_Client/test/Horde/Http/Client/Adapter/FopenTest.php b/framework/Http/test/Horde/Http/FopenTest.php similarity index 66% rename from framework/Http_Client/test/Horde/Http/Client/Adapter/FopenTest.php rename to framework/Http/test/Horde/Http/FopenTest.php index f9f5632fa..7bb7d4e14 100644 --- a/framework/Http_Client/test/Horde/Http/Client/Adapter/FopenTest.php +++ b/framework/Http/test/Horde/Http/FopenTest.php @@ -1,7 +1,7 @@ new Horde_Http_Client_Adapter_Fopen())); + $client = new Horde_Http_Client(array('request' => new Horde_Http_Request_Fopen())); try { $response = $client->get('http://doesntexist.example.com/'); $this->fail(); - } catch (Horde_Http_Client_Exception $e) { + } catch (Horde_Http_Exception $e) { } } public function testReturnsResponseInsteadOfExceptionOn404() { - $client = new Horde_Http_Client(array('adapter' => new Horde_Http_Client_Adapter_Fopen())); + $client = new Horde_Http_Client(array('request' => new Horde_Http_Request_Fopen())); $response = $client->get('http://example.com/doesntexist'); $this->assertEquals(404, $response->code); } diff --git a/framework/Http_Client/lib/Horde/Http/Client/Adapter/Base.php b/framework/Http_Client/lib/Horde/Http/Client/Adapter/Base.php deleted file mode 100644 index 95bf25956..000000000 --- a/framework/Http_Client/lib/Horde/Http/Client/Adapter/Base.php +++ /dev/null @@ -1,74 +0,0 @@ - - * @license http://opensource.org/licenses/bsd-license.php BSD - * @category Horde - * @package Horde_Http_Client - */ - -/** - * @author Chuck Hagenbuch - * @license http://opensource.org/licenses/bsd-license.php BSD - * @category Horde - * @package Horde_Http_Client - */ -class Horde_Http_Client_Adapter_Base -{ - /** - * Proxy server - * @var string - */ - protected $_proxyServer = null; - - /** - * Proxy username - * @var string - */ - protected $_proxyUser = null; - - /** - * Proxy password - * @var string - */ - protected $_proxyPass = null; - - /** - * HTTP timeout - * @var float - */ - protected $_timeout = 5; - - /** - * Constructor - */ - public function __construct($args = array()) - { - foreach ($args as $key => $value) { - $this->$key = $value; - } - } - - /** - * Get an adapter parameter - * - * @param string $name The parameter to get. - * @return mixed Parameter value. - */ - public function __get($name) - { - return isset($this->{'_' . $name}) ? $this->{'_' . $name} : null; - } - - /** - * Set an adapter parameter - * - * @param string $name The parameter to set. - * @param mixed $value Parameter value. - */ - public function __set($name, $value) - { - $this->{'_' . $name} = $value; - } -} diff --git a/framework/Http_Client/package.xml b/framework/Http_Client/package.xml deleted file mode 100644 index fd1c3f24a..000000000 --- a/framework/Http_Client/package.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - Http_Client - pear.horde.org - Horde HTTP client libraries - This package provides a light wrapper around PHP's stream support for performing HTTP requests. - - - Chuck Hagenbuch - chuck - chuck@horde.org - yes - - 2008-09-06 - - 0.3.0 - 0.3.0 - - - beta - beta - - BSD - * Refactor the constructor and setter/getter methods to be more generic. -* Add support for proxy servers. - - - - - - - - - - - - - - - - - - - - - - - - - - - 5.2.0 - - - 1.5.0 - - - - - - - - - - - - - - - - - -- 2.11.0