More phpdoc.
authorJan Schneider <jan@horde.org>
Tue, 12 Jan 2010 10:20:20 +0000 (11:20 +0100)
committerJan Schneider <jan@horde.org>
Tue, 12 Jan 2010 11:46:04 +0000 (12:46 +0100)
framework/Http/lib/Horde/Http/Client.php
framework/Http/lib/Horde/Http/Request/Curl.php
framework/Http/lib/Horde/Http/Request/Fopen.php
framework/Http/lib/Horde/Http/Request/Peclhttp.php
framework/Http/lib/Horde/Http/Response/Base.php
framework/Http/lib/Horde/Http/Response/Curl.php
framework/Http/lib/Horde/Http/Response/Fopen.php
framework/Http/lib/Horde/Http/Response/Peclhttp.php

index 913b461..7698908 100644 (file)
@@ -88,6 +88,7 @@ class Horde_Http_Client
     /**
      * Send a GET request
      *
+     * @throws Horde_Http_Exception
      * @return Horde_Http_Response_Base
      */
     public function get($uri = null, $headers = array())
@@ -98,6 +99,7 @@ class Horde_Http_Client
     /**
      * Send a POST request
      *
+     * @throws Horde_Http_Exception
      * @return Horde_Http_Response_Base
      */
     public function post($uri = null, $data = null, $headers = array())
@@ -108,6 +110,7 @@ class Horde_Http_Client
     /**
      * Send a PUT request
      *
+     * @throws Horde_Http_Exception
      * @return Horde_Http_Response_Base
      */
     public function put($uri = null, $data = null, $headers = array())
@@ -123,6 +126,7 @@ class Horde_Http_Client
     /**
      * Send a DELETE request
      *
+     * @throws Horde_Http_Exception
      * @return Horde_Http_Response_Base
      */
     public function delete($uri = null, $headers = array())
@@ -139,6 +143,7 @@ class Horde_Http_Client
      * Send a HEAD request
      * @TODO
      *
+     * @throws Horde_Http_Exception
      * @return  ? Probably just the status
      */
     public function head($uri = null, $headers = array())
@@ -149,14 +154,15 @@ class Horde_Http_Client
     /**
      * Send an 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.
+     * @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.
      *
+     * @throws Horde_Http_Exception
      * @return Horde_Http_Response_Base
      */
     public function request($method, $uri = null, $data = null, $headers = array())
index 11dc1ca..60b9296 100644 (file)
@@ -17,7 +17,9 @@
 class Horde_Http_Request_Curl extends Horde_Http_Request_Base
 {
     /**
-     * Map of HTTP authentication schemes from Horde_Http constants to HTTP_AUTH constants.
+     * Map of HTTP authentication schemes from Horde_Http constants to
+     * HTTP_AUTH constants.
+     *
      * @var array
      */
     protected $_httpAuthSchemes = array(
@@ -30,6 +32,8 @@ class Horde_Http_Request_Curl extends Horde_Http_Request_Base
 
     /**
      * Constructor
+     *
+     * @throws Horde_Http_Exception
      */
     public function __construct($args = array())
     {
@@ -43,6 +47,7 @@ class Horde_Http_Request_Curl extends Horde_Http_Request_Base
     /**
      * Send this HTTP request
      *
+     * @throws Horde_Http_Exception
      * @return Horde_Http_Response_Base
      */
     public function send()
@@ -60,7 +65,9 @@ class Horde_Http_Request_Curl extends Horde_Http_Request_Base
             // POST data isn't passed.
             $data = http_build_query($data);
         }
-        if ($data) { curl_setopt($curl, CURLOPT_POSTFIELDS, $data); }
+        if ($data) {
+            curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+        }
 
         // Proxy settings
         if ($this->proxyServer) {
@@ -99,6 +106,7 @@ class Horde_Http_Request_Curl extends Horde_Http_Request_Base
      * Translate a Horde_Http::AUTH_* constant to CURLAUTH_*
      *
      * @param const
+     * @throws Horde_Http_Exception
      * @return const
      */
     protected function _httpAuthScheme($httpAuthScheme)
index af36586..d2186fe 100644 (file)
  */
 class Horde_Http_Request_Fopen extends Horde_Http_Request_Base
 {
+    /**
+     * Constructor
+     *
+     * @throws Horde_Http_Exception
+     */
     public function __construct($args = array())
     {
         if (!ini_get('allow_url_fopen')) {
@@ -28,6 +33,7 @@ class Horde_Http_Request_Fopen extends Horde_Http_Request_Base
     /**
      * Send this HTTP request
      *
+     * @throws Horde_Http_Exception
      * @return Horde_Http_Response_Base
      */
     public function send()
index b607bf9..fe5b030 100644 (file)
@@ -57,6 +57,7 @@ class Horde_Http_Request_Peclhttp extends Horde_Http_Request_Base
     /**
      * Send this HTTP request
      *
+     * @throws Horde_Http_Exception
      * @return Horde_Http_Response_Base
      */
     public function send()
@@ -109,6 +110,7 @@ class Horde_Http_Request_Peclhttp extends Horde_Http_Request_Base
      * Translate a Horde_Http::AUTH_* constant to HTTP_AUTH_*
      *
      * @param const
+     * @throws Horde_Http_Exception
      * @return const
      */
     protected function _httpAuthScheme($httpAuthScheme)
index c7e514a..3f1f2c4 100644 (file)
 abstract class Horde_Http_Response_Base
 {
     /**
-     * Fetched URI
+     * Fetched URI.
+     *
      * @var string
      */
     public $uri;
 
     /**
-     * HTTP protocol version that was used
+     * HTTP protocol version that was used.
+     *
      * @var float
      */
     public $httpVersion;
 
     /**
-     * HTTP response code
+     * HTTP response code.
+     *
      * @var integer
      */
     public $code;
 
     /**
-     * Response headers
+     * Response headers.
+     *
      * @var array
      */
     public $headers;
 
     /**
-     * Parse an array of response headers, mindful of line
-     * continuations, etc.
+     * Parses an array of response headers, mindful of line continuations, etc.
      *
      * @param array $headers
+     *
      * @return array
      */
     protected function _parseHeaders($headers)
@@ -57,10 +61,11 @@ abstract class Horde_Http_Response_Base
 
         $lastHeader = null;
         foreach ($headers as $headerLine) {
-            // stream_get_meta returns all headers generated while processing a
-            // request, including ones for redirects before an eventually successful
-            // request. We just want the last one, so whenever we hit a new HTTP
-            // header, throw out anything parsed previously and start over.
+            // stream_get_meta returns all headers generated while processing
+            // a request, including ones for redirects before an eventually
+            // successful request. We just want the last one, so whenever we
+            // hit a new HTTP header, throw out anything parsed previously and
+            // start over.
             if (preg_match('/^HTTP\/(\d.\d) (\d{3})/', $headerLine, $httpMatches)) {
                 $this->httpVersion = $httpMatches[1];
                 $this->code = (int)$httpMatches[2];
@@ -99,15 +104,16 @@ abstract class Horde_Http_Response_Base
     }
 
     /**
-     * Return the body of the HTTP response.
+     * Returns the body of the HTTP response.
      *
+     * @throws Horde_Http_Exception
      * @return string HTTP response body.
      */
     abstract public function getBody();
 
     /**
-     * Return a stream pointing to the response body that can be used
-     * with all standard PHP stream functions.
+     * Returns a stream pointing to the response body that can be used with all
+     * standard PHP stream functions.
      */
     public function getStream()
     {
@@ -116,9 +122,10 @@ abstract class Horde_Http_Response_Base
     }
 
     /**
-     * Get the value of a single response header.
+     * Returns the value of a single response header.
      *
-     * @param string $header Header name to get ('Content-Type', 'Content-Length', etc.). This is case sensitive.
+     * @param string $header  Header name to get ('Content-Type',
+     *                        'Content-Length', etc.). This is case sensitive.
      *
      * @return string HTTP header value.
      */
index f3a1b97..050ab0e 100644 (file)
 class Horde_Http_Response_Curl extends Horde_Http_Response_Base
 {
     /**
-     * Info on the request obtained from curl_getinfo()
+     * Info on the request obtained from curl_getinfo().
+     *
      * @var array
      */
     protected $_info = array();
 
     /**
-     * Response body
+     * Response body.
+     *
      * @var string
      */
     protected $_body;
 
     /**
-     * Constructor
+     * Constructor.
      *
      * @param string $uri
      * @param string $curlresult
@@ -43,7 +45,7 @@ class Horde_Http_Response_Curl extends Horde_Http_Response_Base
     }
 
     /**
-     * Return the body of the HTTP response.
+     * Returns the body of the HTTP response.
      *
      * @return string HTTP response body.
      */
@@ -53,29 +55,26 @@ class Horde_Http_Response_Curl extends Horde_Http_Response_Base
     }
 
     /**
-     * Parse the combined header/body result from cURL.
+     * Parses the combined header/body result from cURL.
      *
      * @param string $curlresult
      */
     protected function _parseResult($curlresult)
     {
         $endOfHeaders = strpos($curlresult, "\r\n\r\n");
-
         $headers = substr($curlresult, 0, $endOfHeaders);
         $this->_parseHeaders($headers);
-
         $this->_body = substr($curlresult, $endOfHeaders + 4);
     }
 
     /**
-     * Process the results of curl_getinfo
+     * Processes the results of curl_getinfo.
      *
      * @param array $curlinfo
      */
     protected function _parseInfo($curlinfo)
     {
         $this->uri = $curlinfo['url'];
-
         $this->_info = $curlinfo;
     }
 }
index 47ea535..7c26a28 100644 (file)
 class Horde_Http_Response_Fopen extends Horde_Http_Response_Base
 {
     /**
-     * Response body
+     * Response body.
+     *
      * @var stream
      */
     protected $_stream;
 
     /**
-     * Constructor
+     * Constructor.
      */
     public function __construct($uri, $stream, $headers = array())
     {
@@ -33,8 +34,9 @@ class Horde_Http_Response_Fopen extends Horde_Http_Response_Base
     }
 
     /**
-     * Return the body of the HTTP response.
+     * Returns the body of the HTTP response.
      *
+     * @throws Horde_Http_Exception
      * @return string HTTP response body.
      */
     public function getBody()
@@ -47,8 +49,8 @@ class Horde_Http_Response_Fopen extends Horde_Http_Response_Base
     }
 
     /**
-     * Return a stream pointing to the response body that can be used
-     * with all standard PHP stream functions.
+     * Returns a stream pointing to the response body that can be used with
+     * all standard PHP stream functions.
      */
     public function getStream()
     {
index 27063ba..bbfb946 100644 (file)
 class Horde_Http_Response_Peclhttp extends Horde_Http_Response_Base
 {
     /**
-     * HttpMessage object
+     * HttpMessage object.
+     *
      * @var HttpMessage
      */
     protected $_message;
 
     /**
-     * Constructor
+     * Constructor.
      *
      * @param string $uri
      * @param HttpMessage $message
@@ -33,9 +34,7 @@ class Horde_Http_Response_Peclhttp extends Horde_Http_Response_Base
         $this->uri = $uri;
         $this->httpVersion = $message->getHttpVersion();
         $this->code = $message->getResponseCode();
-
         $this->_message = $message;
-
         foreach ($message->getHeaders() as $k => $v) {
             $this->headers[strtolower($k)] = $v;
         }