]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - extlib/HTTP/Request2/Adapter.php
Updating external libraries for net access
[quix0rs-gnu-social.git] / extlib / HTTP / Request2 / Adapter.php
index 2cabbf897b8ddcbe3e2a54d549461d3d7e70ac3a..3ab7d38cc3b2baa8293c8f3501ee9059aeeabd30 100644 (file)
@@ -6,7 +6,7 @@
  *\r
  * LICENSE:\r
  *\r
- * Copyright (c) 2008-2011, Alexey Borzov <avb@php.net>\r
+ * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
  * All rights reserved.\r
  *\r
  * Redistribution and use in source and binary forms, with or without\r
  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\r
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
  *\r
- * @category   HTTP\r
- * @package    HTTP_Request2\r
- * @author     Alexey Borzov <avb@php.net>\r
- * @license    http://opensource.org/licenses/bsd-license.php New BSD License\r
- * @version    SVN: $Id: Adapter.php 308322 2011-02-14 13:58:03Z avb $\r
- * @link       http://pear.php.net/package/HTTP_Request2\r
+ * @category HTTP\r
+ * @package  HTTP_Request2\r
+ * @author   Alexey Borzov <avb@php.net>\r
+ * @license  http://opensource.org/licenses/bsd-license.php New BSD License\r
+ * @version  SVN: $Id: Adapter.php 324415 2012-03-21 10:50:50Z avb $\r
+ * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /**\r
@@ -53,66 +53,69 @@ require_once 'HTTP/Request2/Response.php';
  * data, all actual work of sending the request to the remote server and\r
  * receiving its response is performed by adapters.\r
  *\r
- * @category   HTTP\r
- * @package    HTTP_Request2\r
- * @author     Alexey Borzov <avb@php.net>\r
- * @version    Release: 2.0.0RC1\r
+ * @category HTTP\r
+ * @package  HTTP_Request2\r
+ * @author   Alexey Borzov <avb@php.net>\r
+ * @license  http://opensource.org/licenses/bsd-license.php New BSD License\r
+ * @version  Release: 2.1.1\r
+ * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
 abstract class HTTP_Request2_Adapter\r
 {\r
-   /**\r
-    * A list of methods that MUST NOT have a request body, per RFC 2616\r
-    * @var  array\r
-    */\r
+    /**\r
+     * A list of methods that MUST NOT have a request body, per RFC 2616\r
+     * @var  array\r
+     */\r
     protected static $bodyDisallowed = array('TRACE');\r
 \r
-   /**\r
-    * Methods having defined semantics for request body\r
-    *\r
-    * Content-Length header (indicating that the body follows, section 4.3 of\r
-    * RFC 2616) will be sent for these methods even if no body was added\r
-    *\r
-    * @var  array\r
-    * @link http://pear.php.net/bugs/bug.php?id=12900\r
-    * @link http://pear.php.net/bugs/bug.php?id=14740\r
-    */\r
+    /**\r
+     * Methods having defined semantics for request body\r
+     *\r
+     * Content-Length header (indicating that the body follows, section 4.3 of\r
+     * RFC 2616) will be sent for these methods even if no body was added\r
+     *\r
+     * @var  array\r
+     * @link http://pear.php.net/bugs/bug.php?id=12900\r
+     * @link http://pear.php.net/bugs/bug.php?id=14740\r
+     */\r
     protected static $bodyRequired = array('POST', 'PUT');\r
 \r
-   /**\r
-    * Request being sent\r
-    * @var  HTTP_Request2\r
-    */\r
+    /**\r
+     * Request being sent\r
+     * @var  HTTP_Request2\r
+     */\r
     protected $request;\r
 \r
-   /**\r
-    * Request body\r
-    * @var  string|resource|HTTP_Request2_MultipartBody\r
-    * @see  HTTP_Request2::getBody()\r
-    */\r
+    /**\r
+     * Request body\r
+     * @var  string|resource|HTTP_Request2_MultipartBody\r
+     * @see  HTTP_Request2::getBody()\r
+     */\r
     protected $requestBody;\r
 \r
-   /**\r
-    * Length of the request body\r
-    * @var  integer\r
-    */\r
+    /**\r
+     * Length of the request body\r
+     * @var  integer\r
+     */\r
     protected $contentLength;\r
 \r
-   /**\r
-    * Sends request to the remote server and returns its response\r
-    *\r
-    * @param    HTTP_Request2\r
-    * @return   HTTP_Request2_Response\r
-    * @throws   HTTP_Request2_Exception\r
-    */\r
+    /**\r
+     * Sends request to the remote server and returns its response\r
+     *\r
+     * @param HTTP_Request2 $request HTTP request message\r
+     *\r
+     * @return   HTTP_Request2_Response\r
+     * @throws   HTTP_Request2_Exception\r
+     */\r
     abstract public function sendRequest(HTTP_Request2 $request);\r
 \r
-   /**\r
-    * Calculates length of the request body, adds proper headers\r
-    *\r
-    * @param    array   associative array of request headers, this method will\r
-    *                   add proper 'Content-Length' and 'Content-Type' headers\r
-    *                   to this array (or remove them if not needed)\r
-    */\r
+    /**\r
+     * Calculates length of the request body, adds proper headers\r
+     *\r
+     * @param array &$headers associative array of request headers, this method\r
+     *                        will add proper 'Content-Length' and 'Content-Type'\r
+     *                        headers to this array (or remove them if not needed)\r
+     */\r
     protected function calculateRequestLength(&$headers)\r
     {\r
         $this->requestBody = $this->request->getBody();\r
@@ -130,8 +133,8 @@ abstract class HTTP_Request2_Adapter
             $this->requestBody->rewind();\r
         }\r
 \r
-        if (in_array($this->request->getMethod(), self::$bodyDisallowed) ||\r
-            0 == $this->contentLength\r
+        if (in_array($this->request->getMethod(), self::$bodyDisallowed)\r
+            || 0 == $this->contentLength\r
         ) {\r
             // No body: send a Content-Length header nonetheless (request #12900),\r
             // but do that only for methods that require a body (bug #14740)\r