]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
PEAR::HTTP_Request2 updated to 2.2.1
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 10 Jul 2014 14:23:21 +0000 (16:23 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 10 Jul 2014 14:25:59 +0000 (16:25 +0200)
Release date: 2014-01-16 19:53 UTC

13 files changed:
extlib/HTTP/Request2.php
extlib/HTTP/Request2/Adapter.php
extlib/HTTP/Request2/Adapter/Curl.php
extlib/HTTP/Request2/Adapter/Mock.php
extlib/HTTP/Request2/Adapter/Socket.php
extlib/HTTP/Request2/CookieJar.php
extlib/HTTP/Request2/Exception.php
extlib/HTTP/Request2/MultipartBody.php
extlib/HTTP/Request2/Observer/Log.php
extlib/HTTP/Request2/Response.php
extlib/HTTP/Request2/SOCKS5.php
extlib/HTTP/Request2/SocketWrapper.php
extlib/HTTP_Request2_LICENSE [new file with mode: 0644]

index 1a40df22139f7c770f1569f36ae5e0f8b400baed..d2f36e17b9cbdacc2275dedc4c8a1b97b55d85f6 100644 (file)
@@ -4,41 +4,18 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
+ * LICENSE\r
  *\r
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
- * All rights reserved.\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
  *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *    * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *    * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *    * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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: Request2.php 324936 2012-04-07 07:49: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
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /**\r
@@ -57,8 +34,8 @@ require_once 'HTTP/Request2/Exception.php';
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  * @link     http://tools.ietf.org/html/rfc2616#section-5\r
  */\r
@@ -152,6 +129,7 @@ class HTTP_Request2 implements SplSubject
         'protocol_version'  => '1.1',\r
         'buffer_size'       => 16384,\r
         'store_body'        => true,\r
+        'local_ip'          => null,\r
 \r
         'proxy_host'        => '',\r
         'proxy_port'        => '',\r
@@ -235,7 +213,7 @@ class HTTP_Request2 implements SplSubject
             $this->setMethod($method);\r
         }\r
         $this->setHeader(\r
-            'user-agent', 'HTTP_Request2/2.1.1 ' .\r
+            'user-agent', 'HTTP_Request2/2.2.1 ' .\r
             '(http://pear.php.net/package/http_request2) PHP/' . phpversion()\r
         );\r
     }\r
@@ -338,6 +316,8 @@ class HTTP_Request2 implements SplSubject
      *   <li> 'store_body'        - Whether to store response body in response object.\r
      *                              Set to false if receiving a huge response and\r
      *                              using an Observer to save it (boolean)</li>\r
+     *   <li> 'local_ip'          - Specifies the IP address that will be used for accessing\r
+     *                              the network (string)</li>\r
      *   <li> 'proxy_type'        - Proxy type, 'http' or 'socks5' (string)</li>\r
      *   <li> 'proxy_host'        - Proxy server host (string)</li>\r
      *   <li> 'proxy_port'        - Proxy server port (integer)</li>\r
index 3ab7d38cc3b2baa8293c8f3501ee9059aeeabd30..4e4b0b10a3a3e660422ea7d8dc6775502e8fac82 100644 (file)
@@ -4,41 +4,18 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
+ * LICENSE\r
  *\r
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
- * All rights reserved.\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
  *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *    * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *    * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *    * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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 324415 2012-03-21 10:50:50Z 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
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /**\r
@@ -56,8 +33,8 @@ require_once 'HTTP/Request2/Response.php';
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
 abstract class HTTP_Request2_Adapter\r
@@ -150,7 +127,10 @@ abstract class HTTP_Request2_Adapter
             if (empty($headers['content-type'])) {\r
                 $headers['content-type'] = 'application/x-www-form-urlencoded';\r
             }\r
-            $headers['content-length'] = $this->contentLength;\r
+            // Content-Length should not be sent for chunked Transfer-Encoding (bug #20125)\r
+            if (!isset($headers['transfer-encoding'])) {\r
+                $headers['content-length'] = $this->contentLength;\r
+            }\r
         }\r
     }\r
 }\r
index c80c94584e5d0a35a38ab783edf97f2b71423d92..ef75b8c9576215eb4dfb27345df6fc4c72e232dd 100644 (file)
@@ -4,41 +4,18 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
+ * LICENSE\r
  *\r
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
- * All rights reserved.\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
  *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *    * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *    * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *    * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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: Curl.php 324746 2012-04-03 15:09:16Z 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
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /**\r
@@ -52,8 +29,8 @@ require_once 'HTTP/Request2/Adapter.php';
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
 class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter\r
@@ -238,6 +215,7 @@ class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter
      *\r
      * @return   resource    a cURL handle, as created by curl_init()\r
      * @throws   HTTP_Request2_LogicException\r
+     * @throws   HTTP_Request2_NotImplementedException\r
      */\r
     protected function createCurlHandle()\r
     {\r
@@ -278,6 +256,11 @@ class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter
             }\r
         }\r
 \r
+        // set local IP via CURLOPT_INTERFACE (request #19515)\r
+        if ($ip = $this->request->getConfig('local_ip')) {\r
+            curl_setopt($ch, CURLOPT_INTERFACE, $ip);\r
+        }\r
+\r
         // request timeout\r
         if ($timeout = $this->request->getConfig('timeout')) {\r
             curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);\r
@@ -389,7 +372,7 @@ class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter
         }\r
 \r
         $this->calculateRequestLength($headers);\r
-        if (isset($headers['content-length'])) {\r
+        if (isset($headers['content-length']) || isset($headers['transfer-encoding'])) {\r
             $this->workaroundPhpBug47204($ch, $headers);\r
         }\r
 \r
index 29d48dbb749af962938815a0ac94aecf7da7cc5d..d6e274ab9a1dc05b6a0d9c22fe4e5079d5cfb52c 100644 (file)
@@ -4,41 +4,18 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
+ * LICENSE\r
  *\r
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
- * All rights reserved.\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
  *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *    * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *    * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *    * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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: Mock.php 324937 2012-04-07 10:05:57Z 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
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /**\r
@@ -66,8 +43,8 @@ require_once 'HTTP/Request2/Adapter.php';
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
 class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter\r
index fb2940a2ee352a8c46125f1b3eb086f66e7d80c6..7946b0a37410cb8af78078431813dbc97017cb1a 100644 (file)
@@ -4,41 +4,18 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
+ * LICENSE\r
  *\r
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
- * All rights reserved.\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
  *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *    * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *    * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *    * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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: Socket.php 324953 2012-04-08 07:24:12Z 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
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /** Base class for HTTP_Request2 adapters */\r
@@ -56,8 +33,8 @@ require_once 'HTTP/Request2/SocketWrapper.php';
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
 class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter\r
@@ -70,7 +47,7 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter
     /**\r
      * Regular expression for 'quoted-string' rule from RFC 2616\r
      */\r
-    const REGEXP_QUOTED_STRING = '"(?:\\\\.|[^\\\\"])*"';\r
+    const REGEXP_QUOTED_STRING = '"(?>[^"\\\\]+|\\\\.)*"';\r
 \r
     /**\r
      * Connected sockets, needed for Keep-Alive support\r
@@ -129,6 +106,12 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter
      */\r
     protected $redirectCountdown = null;\r
 \r
+    /**\r
+     * Whether to wait for "100 Continue" response before sending request body\r
+     * @var bool\r
+     */\r
+    protected $expect100Continue = false;\r
+\r
     /**\r
      * Sends request to the remote server and returns its response\r
      *\r
@@ -147,9 +130,21 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter
             $this->socket->write($headers);\r
             // provide request headers to the observer, see request #7633\r
             $this->request->setLastEvent('sentHeaders', $headers);\r
-            $this->writeBody();\r
 \r
-            $response = $this->readResponse();\r
+            if (!$this->expect100Continue) {\r
+                $this->writeBody();\r
+                $response = $this->readResponse();\r
+\r
+            } else {\r
+                $response = $this->readResponse();\r
+                if (!$response || 100 == $response->getStatus()) {\r
+                    $this->expect100Continue = false;\r
+                    // either got "100 Continue" or timed out -> send body\r
+                    $this->writeBody();\r
+                    $response = $this->readResponse();\r
+                }\r
+            }\r
+\r
 \r
             if ($jar = $request->getCookieJar()) {\r
                 $jar->addCookiesFromResponse($response, $request->getUrl());\r
@@ -256,19 +251,25 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter
                       'Keep-Alive' == $headers['connection']);\r
 \r
         $options = array();\r
+        if ($ip = $this->request->getConfig('local_ip')) {\r
+            $options['socket'] = array(\r
+                'bindto' => (false === strpos($ip, ':') ? $ip : '[' . $ip . ']') . ':0'\r
+            );\r
+        }\r
         if ($secure || $tunnel) {\r
+            $options['ssl'] = array();\r
             foreach ($this->request->getConfig() as $name => $value) {\r
                 if ('ssl_' == substr($name, 0, 4) && null !== $value) {\r
                     if ('ssl_verify_host' == $name) {\r
                         if ($value) {\r
-                            $options['CN_match'] = $reqHost;\r
+                            $options['ssl']['CN_match'] = $reqHost;\r
                         }\r
                     } else {\r
-                        $options[substr($name, 4)] = $value;\r
+                        $options['ssl'][substr($name, 4)] = $value;\r
                     }\r
                 }\r
             }\r
-            ksort($options);\r
+            ksort($options['ssl']);\r
         }\r
 \r
         // Use global request timeout if given, see feature requests #5735, #8964\r
@@ -863,6 +864,11 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter
         $this->addAuthorizationHeader($headers, $host, $requestUrl);\r
         $this->addProxyAuthorizationHeader($headers, $requestUrl);\r
         $this->calculateRequestLength($headers);\r
+        if ('1.1' == $this->request->getConfig('protocol_version')) {\r
+            $this->updateExpectHeader($headers);\r
+        } else {\r
+            $this->expect100Continue = false;\r
+        }\r
 \r
         $headersStr = $this->request->getMethod() . ' ' . $requestUrl . ' HTTP/' .\r
                       $this->request->getConfig('protocol_version') . "\r\n";\r
@@ -873,6 +879,78 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter
         return $headersStr . "\r\n";\r
     }\r
 \r
+    /**\r
+     * Adds or removes 'Expect: 100-continue' header from request headers\r
+     *\r
+     * Also sets the $expect100Continue property. Parsing of existing header\r
+     * is somewhat needed due to its complex structure and due to the\r
+     * requirement in section 8.2.3 of RFC 2616:\r
+     * > A client MUST NOT send an Expect request-header field (section\r
+     * > 14.20) with the "100-continue" expectation if it does not intend\r
+     * > to send a request body.\r
+     *\r
+     * @param array &$headers Array of headers prepared for the request\r
+     *\r
+     * @throws HTTP_Request2_LogicException\r
+     * @link http://pear.php.net/bugs/bug.php?id=19233\r
+     * @link http://tools.ietf.org/html/rfc2616#section-8.2.3\r
+     */\r
+    protected function updateExpectHeader(&$headers)\r
+    {\r
+        $this->expect100Continue = false;\r
+        $expectations = array();\r
+        if (isset($headers['expect'])) {\r
+            if ('' === $headers['expect']) {\r
+                // empty 'Expect' header is technically invalid, so just get rid of it\r
+                unset($headers['expect']);\r
+                return;\r
+            }\r
+            // build regexp to parse the value of existing Expect header\r
+            $expectParam     = ';\s*' . self::REGEXP_TOKEN . '(?:\s*=\s*(?:'\r
+                               . self::REGEXP_TOKEN . '|'\r
+                               . self::REGEXP_QUOTED_STRING . '))?\s*';\r
+            $expectExtension = self::REGEXP_TOKEN . '(?:\s*=\s*(?:'\r
+                               . self::REGEXP_TOKEN . '|'\r
+                               . self::REGEXP_QUOTED_STRING . ')\s*(?:'\r
+                               . $expectParam . ')*)?';\r
+            $expectItem      = '!(100-continue|' . $expectExtension . ')!A';\r
+\r
+            $pos    = 0;\r
+            $length = strlen($headers['expect']);\r
+\r
+            while ($pos < $length) {\r
+                $pos += strspn($headers['expect'], " \t", $pos);\r
+                if (',' === substr($headers['expect'], $pos, 1)) {\r
+                    $pos++;\r
+                    continue;\r
+\r
+                } elseif (!preg_match($expectItem, $headers['expect'], $m, 0, $pos)) {\r
+                    throw new HTTP_Request2_LogicException(\r
+                        "Cannot parse value '{$headers['expect']}' of Expect header",\r
+                        HTTP_Request2_Exception::INVALID_ARGUMENT\r
+                    );\r
+\r
+                } else {\r
+                    $pos += strlen($m[0]);\r
+                    if (strcasecmp('100-continue', $m[0])) {\r
+                        $expectations[]  = $m[0];\r
+                    }\r
+                }\r
+            }\r
+        }\r
+\r
+        if (1024 < $this->contentLength) {\r
+            $expectations[] = '100-continue';\r
+            $this->expect100Continue = true;\r
+        }\r
+\r
+        if (empty($expectations)) {\r
+            unset($headers['expect']);\r
+        } else {\r
+            $headers['expect'] = implode(',', $expectations);\r
+        }\r
+    }\r
+\r
     /**\r
      * Sends the request body\r
      *\r
@@ -888,6 +966,8 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter
 \r
         $position   = 0;\r
         $bufferSize = $this->request->getConfig('buffer_size');\r
+        $headers    = $this->request->getHeaders();\r
+        $chunked    = isset($headers['transfer-encoding']);\r
         while ($position < $this->contentLength) {\r
             if (is_string($this->requestBody)) {\r
                 $str = substr($this->requestBody, $position, $bufferSize);\r
@@ -896,11 +976,20 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter
             } else {\r
                 $str = $this->requestBody->read($bufferSize);\r
             }\r
-            $this->socket->write($str);\r
+            if (!$chunked) {\r
+                $this->socket->write($str);\r
+            } else {\r
+                $this->socket->write(dechex(strlen($str)) . "\r\n{$str}\r\n");\r
+            }\r
             // Provide the length of written string to the observer, request #7630\r
             $this->request->setLastEvent('sentBodyPart', strlen($str));\r
             $position += strlen($str);\r
         }\r
+\r
+        // write zero-length chunk\r
+        if ($chunked) {\r
+            $this->socket->write("0\r\n\r\n");\r
+        }\r
         $this->request->setLastEvent('sentBody', $this->contentLength);\r
     }\r
 \r
@@ -913,15 +1002,31 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter
     protected function readResponse()\r
     {\r
         $bufferSize = $this->request->getConfig('buffer_size');\r
+        // http://tools.ietf.org/html/rfc2616#section-8.2.3\r
+        // ...the client SHOULD NOT wait for an indefinite period before sending the request body\r
+        $timeout    = $this->expect100Continue ? 1 : null;\r
 \r
         do {\r
-            $response = new HTTP_Request2_Response(\r
-                $this->socket->readLine($bufferSize), true, $this->request->getUrl()\r
-            );\r
-            do {\r
-                $headerLine = $this->socket->readLine($bufferSize);\r
-                $response->parseHeaderLine($headerLine);\r
-            } while ('' != $headerLine);\r
+            try {\r
+                $response = new HTTP_Request2_Response(\r
+                    $this->socket->readLine($bufferSize, $timeout), true, $this->request->getUrl()\r
+                );\r
+                do {\r
+                    $headerLine = $this->socket->readLine($bufferSize);\r
+                    $response->parseHeaderLine($headerLine);\r
+                } while ('' != $headerLine);\r
+\r
+            } catch (HTTP_Request2_MessageException $e) {\r
+                if (HTTP_Request2_Exception::TIMEOUT === $e->getCode()\r
+                    && $this->expect100Continue\r
+                ) {\r
+                    return null;\r
+                }\r
+                throw $e;\r
+            }\r
+            if ($this->expect100Continue && 100 == $response->getStatus()) {\r
+                return $response;\r
+            }\r
         } while (in_array($response->getStatus(), array(100, 101)));\r
 \r
         $this->request->setLastEvent('receivedHeaders', $response);\r
index 904186791ab8c3ff7db66fbdc1a803db6475da27..79ac08bb7578073967e19c27ec8762eb4415d299 100644 (file)
@@ -4,41 +4,18 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
+ * LICENSE\r
  *\r
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
- * All rights reserved.\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
  *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *    * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *    * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *    * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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: CookieJar.php 324415 2012-03-21 10:50:50Z 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
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /** Class representing a HTTP request message */\r
@@ -50,7 +27,7 @@ require_once 'HTTP/Request2.php';
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
  * @version  Release: @package_version@\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
index b7b8d8d0379eb82417900d81f97b9276d2707db1..d0b5d4ee099acd3af2a1f0009fa14836aee95689 100644 (file)
@@ -4,41 +4,18 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
- *\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
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *    * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *    * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *    * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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: Exception.php 324415 2012-03-21 10:50:50Z avb $\r
- * @link     http://pear.php.net/package/HTTP_Request2\r
+ * LICENSE\r
+ *\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
+ *\r
+ * @category  HTTP\r
+ * @package   HTTP_Request2\r
+ * @author    Alexey Borzov <avb@php.net>\r
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /**\r
@@ -52,8 +29,8 @@ require_once 'PEAR/Exception.php';
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  * @link     http://pear.php.net/pepr/pepr-proposal-show.php?id=132\r
  */\r
@@ -119,8 +96,8 @@ class HTTP_Request2_Exception extends PEAR_Exception
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
 class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception\r
@@ -140,8 +117,8 @@ class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
 class HTTP_Request2_LogicException extends HTTP_Request2_Exception\r
@@ -157,8 +134,8 @@ class HTTP_Request2_LogicException extends HTTP_Request2_Exception
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
 class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception\r
@@ -173,8 +150,8 @@ class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
 class HTTP_Request2_MessageException extends HTTP_Request2_Exception\r
index 53e0c1b9eabfdda4a26ffeb1e9032317e5657593..c68b6602b8ab0634d68f25f49653ed42e82dd9df 100644 (file)
@@ -4,43 +4,23 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
+ * LICENSE\r
  *\r
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
- * All rights reserved.\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
  *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *    * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *    * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *    * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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: MultipartBody.php 324415 2012-03-21 10:50:50Z 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
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
+/** Exception class for HTTP_Request2 package */\r
+require_once 'HTTP/Request2/Exception.php';\r
+\r
 /**\r
  * Class for building multipart/form-data request body\r
  *\r
@@ -50,8 +30,8 @@
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  * @link     http://tools.ietf.org/html/rfc1867\r
  */\r
@@ -167,6 +147,7 @@ class HTTP_Request2_MultipartBody
      * @param integer $length Number of bytes to read\r
      *\r
      * @return   string  Up to $length bytes of data, empty string if at end\r
+     * @throws   HTTP_Request2_LogicException\r
      */\r
     public function read($length)\r
     {\r
@@ -194,9 +175,16 @@ class HTTP_Request2_MultipartBody
                     $length -= min(strlen($header) - $this->_pos[1], $length);\r
                 }\r
                 $filePos  = max(0, $this->_pos[1] - strlen($header));\r
-                if ($length > 0 && $filePos < $this->_uploads[$pos]['size']) {\r
-                    $ret     .= fread($this->_uploads[$pos]['fp'], $length);\r
-                    $length  -= min($length, $this->_uploads[$pos]['size'] - $filePos);\r
+                if ($filePos < $this->_uploads[$pos]['size']) {\r
+                    while ($length > 0 && !feof($this->_uploads[$pos]['fp'])) {\r
+                        if (false === ($chunk = fread($this->_uploads[$pos]['fp'], $length))) {\r
+                            throw new HTTP_Request2_LogicException(\r
+                                'Failed reading file upload', HTTP_Request2_Exception::READ_ERROR\r
+                            );\r
+                        }\r
+                        $ret    .= $chunk;\r
+                        $length -= strlen($chunk);\r
+                    }\r
                 }\r
                 if ($length > 0) {\r
                     $start   = $this->_pos[1] + ($oldLength - $length) -\r
index 8520f61c2136c13d13ade95a003bfd68e7dc827a..341e29907ee5fca0739afb99e99fef45bf17bb28 100644 (file)
@@ -4,42 +4,19 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
+ * LICENSE\r
  *\r
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
- * All rights reserved.\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
  *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *    * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *    * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *    * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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   David Jean Louis <izi@php.net>\r
- * @author   Alexey Borzov <avb@php.net>\r
- * @license  http://opensource.org/licenses/bsd-license.php New BSD License\r
- * @version  SVN: $Id: Log.php 324415 2012-03-21 10:50:50Z avb $\r
- * @link     http://pear.php.net/package/HTTP_Request2\r
+ * @category  HTTP\r
+ * @package   HTTP_Request2\r
+ * @author    David Jean Louis <izi@php.net>\r
+ * @author    Alexey Borzov <avb@php.net>\r
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /**\r
@@ -86,8 +63,8 @@ require_once 'HTTP/Request2/Exception.php';
  * @package  HTTP_Request2\r
  * @author   David Jean Louis <izi@php.net>\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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  */\r
 class HTTP_Request2_Observer_Log implements SplObserver\r
index 96682d795ba81f3006b83bdf8bbcebe36ebd13ee..d2f414cf6c3518ff567c81ee6c4315b45ea940cf 100644 (file)
@@ -4,41 +4,18 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
+ * LICENSE\r
  *\r
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
- * All rights reserved.\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
  *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *     * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *     * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *     * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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: Response.php 324936 2012-04-07 07:49: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
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /**\r
@@ -69,8 +46,8 @@ require_once 'HTTP/Request2/Exception.php';
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  * @link     http://tools.ietf.org/html/rfc2616#section-6\r
  */\r
index 518289e9c7c3681f9a237ff404370e9b712b0d3f..d54049585946ac90e49d58a63ef8c4d6130ee262 100644 (file)
@@ -4,41 +4,18 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
+ * LICENSE\r
  *\r
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
- * All rights reserved.\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
  *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *    * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *    * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *    * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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: SOCKS5.php 324953 2012-04-08 07:24:12Z 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
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /** Socket wrapper class used by Socket Adapter */\r
@@ -50,8 +27,8 @@ require_once 'HTTP/Request2/SocketWrapper.php';
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  * @link     http://pear.php.net/bugs/bug.php?id=19332\r
  * @link     http://tools.ietf.org/html/rfc1928\r
@@ -61,21 +38,21 @@ class HTTP_Request2_SOCKS5 extends HTTP_Request2_SocketWrapper
     /**\r
      * Constructor, tries to connect and authenticate to a SOCKS5 proxy\r
      *\r
-     * @param string $address    Proxy address, e.g. 'tcp://localhost:1080'\r
-     * @param int    $timeout    Connection timeout (seconds)\r
-     * @param array  $sslOptions SSL context options\r
-     * @param string $username   Proxy user name\r
-     * @param string $password   Proxy password\r
+     * @param string $address        Proxy address, e.g. 'tcp://localhost:1080'\r
+     * @param int    $timeout        Connection timeout (seconds)\r
+     * @param array  $contextOptions Stream context options\r
+     * @param string $username       Proxy user name\r
+     * @param string $password       Proxy password\r
      *\r
      * @throws HTTP_Request2_LogicException\r
      * @throws HTTP_Request2_ConnectionException\r
      * @throws HTTP_Request2_MessageException\r
      */\r
     public function __construct(\r
-        $address, $timeout = 10, array $sslOptions = array(),\r
+        $address, $timeout = 10, array $contextOptions = array(),\r
         $username = null, $password = null\r
     ) {\r
-        parent::__construct($address, $timeout, $sslOptions);\r
+        parent::__construct($address, $timeout, $contextOptions);\r
 \r
         if (strlen($username)) {\r
             $request = pack('C4', 5, 2, 0, 2);\r
index f56af406bc0b568d003a605b38a2f5cc3d168d37..43081a19663db1943a7423339888b88b566e8820 100644 (file)
@@ -4,41 +4,18 @@
  *\r
  * PHP version 5\r
  *\r
- * LICENSE:\r
+ * LICENSE\r
  *\r
- * Copyright (c) 2008-2012, Alexey Borzov <avb@php.net>\r
- * All rights reserved.\r
+ * This source file is subject to BSD 3-Clause License that is bundled\r
+ * with this package in the file LICENSE and available at the URL\r
+ * https://raw.github.com/pear/HTTP_Request2/trunk/docs/LICENSE\r
  *\r
- * Redistribution and use in source and binary forms, with or without\r
- * modification, are permitted provided that the following conditions\r
- * are met:\r
- *\r
- *    * Redistributions of source code must retain the above copyright\r
- *      notice, this list of conditions and the following disclaimer.\r
- *    * Redistributions in binary form must reproduce the above copyright\r
- *      notice, this list of conditions and the following disclaimer in the\r
- *      documentation and/or other materials provided with the distribution.\r
- *    * The names of the authors may not be used to endorse or promote products\r
- *      derived from this software without specific prior written permission.\r
- *\r
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS\r
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\r
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY\r
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\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: SocketWrapper.php 324935 2012-04-07 07:10:50Z 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
+ * @copyright 2008-2014 Alexey Borzov <avb@php.net>\r
+ * @license   http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @link      http://pear.php.net/package/HTTP_Request2\r
  */\r
 \r
 /** Exception classes for HTTP_Request2 package */\r
@@ -53,8 +30,8 @@ require_once 'HTTP/Request2/Exception.php';
  * @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
+ * @license  http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License\r
+ * @version  Release: 2.2.1\r
  * @link     http://pear.php.net/package/HTTP_Request2\r
  * @link     http://pear.php.net/bugs/bug.php?id=19332\r
  * @link     http://tools.ietf.org/html/rfc1928\r
@@ -88,22 +65,30 @@ class HTTP_Request2_SocketWrapper
     /**\r
      * Class constructor, tries to establish connection\r
      *\r
-     * @param string $address    Address for stream_socket_client() call,\r
-     *                           e.g. 'tcp://localhost:80'\r
-     * @param int    $timeout    Connection timeout (seconds)\r
-     * @param array  $sslOptions SSL context options\r
+     * @param string $address        Address for stream_socket_client() call,\r
+     *                               e.g. 'tcp://localhost:80'\r
+     * @param int    $timeout        Connection timeout (seconds)\r
+     * @param array  $contextOptions Context options\r
      *\r
      * @throws HTTP_Request2_LogicException\r
      * @throws HTTP_Request2_ConnectionException\r
      */\r
-    public function __construct($address, $timeout, array $sslOptions = array())\r
+    public function __construct($address, $timeout, array $contextOptions = array())\r
     {\r
+        if (!empty($contextOptions)\r
+            && !isset($contextOptions['socket']) && !isset($contextOptions['ssl'])\r
+        ) {\r
+            // Backwards compatibility with 2.1.0 and 2.1.1 releases\r
+            $contextOptions = array('ssl' => $contextOptions);\r
+        }\r
         $context = stream_context_create();\r
-        foreach ($sslOptions as $name => $value) {\r
-            if (!stream_context_set_option($context, 'ssl', $name, $value)) {\r
-                throw new HTTP_Request2_LogicException(\r
-                    "Error setting SSL context option '{$name}'"\r
-                );\r
+        foreach ($contextOptions as $wrapper => $options) {\r
+            foreach ($options as $name => $value) {\r
+                if (!stream_context_set_option($context, $wrapper, $name, $value)) {\r
+                    throw new HTTP_Request2_LogicException(\r
+                        "Error setting '{$wrapper}' wrapper context option '{$name}'"\r
+                    );\r
+                }\r
             }\r
         }\r
         set_error_handler(array($this, 'connectionWarningsHandler'));\r
@@ -111,7 +96,14 @@ class HTTP_Request2_SocketWrapper
             $address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context\r
         );\r
         restore_error_handler();\r
-        if (!$this->socket) {\r
+        // if we fail to bind to a specified local address (see request #19515),\r
+        // connection still succeeds, albeit with a warning. Throw an Exception\r
+        // with the warning text in this case as that connection is unlikely\r
+        // to be what user wants and as Curl throws an error in similar case.\r
+        if ($this->connectionWarnings) {\r
+            if ($this->socket) {\r
+                fclose($this->socket);\r
+            }\r
             $error = $errstr ? $errstr : implode("\n", $this->connectionWarnings);\r
             throw new HTTP_Request2_ConnectionException(\r
                 "Unable to connect to {$address}. Error: {$error}", 0, $errno\r
@@ -151,20 +143,42 @@ class HTTP_Request2_SocketWrapper
      * Strips the trailing newline from the returned data, handles global\r
      * request timeout. Method idea borrowed from Net_Socket PEAR package.\r
      *\r
-     * @param int $bufferSize buffer size to use for reading\r
+     * @param int $bufferSize   buffer size to use for reading\r
+     * @param int $localTimeout timeout value to use just for this call\r
+     *                          (used when waiting for "100 Continue" response)\r
      *\r
      * @return   string Available data up to the newline (not including newline)\r
      * @throws   HTTP_Request2_MessageException     In case of timeout\r
      */\r
-    public function readLine($bufferSize)\r
+    public function readLine($bufferSize, $localTimeout = null)\r
     {\r
         $line = '';\r
         while (!feof($this->socket)) {\r
-            if ($this->deadline) {\r
+            if (null !== $localTimeout) {\r
+                stream_set_timeout($this->socket, $localTimeout);\r
+            } elseif ($this->deadline) {\r
                 stream_set_timeout($this->socket, max($this->deadline - time(), 1));\r
             }\r
+\r
             $line .= @fgets($this->socket, $bufferSize);\r
-            $this->checkTimeout();\r
+\r
+            if (null === $localTimeout) {\r
+                $this->checkTimeout();\r
+\r
+            } else {\r
+                $info = stream_get_meta_data($this->socket);\r
+                // reset socket timeout if we don't have request timeout specified,\r
+                // prevents further calls failing with a bogus Exception\r
+                if (!$this->deadline) {\r
+                    $default = (int)@ini_get('default_socket_timeout');\r
+                    stream_set_timeout($this->socket, $default > 0 ? $default : PHP_INT_MAX);\r
+                }\r
+                if ($info['timed_out']) {\r
+                    throw new HTTP_Request2_MessageException(\r
+                        "readLine() call timed out", HTTP_Request2_Exception::TIMEOUT\r
+                    );\r
+                }\r
+            }\r
             if (substr($line, -1) == "\n") {\r
                 return rtrim($line, "\r\n");\r
             }\r
diff --git a/extlib/HTTP_Request2_LICENSE b/extlib/HTTP_Request2_LICENSE
new file mode 100644 (file)
index 0000000..95406a3
--- /dev/null
@@ -0,0 +1,31 @@
+HTTP_Request2\r
+\r
+Copyright (c) 2008-2014, Alexey Borzov <avb@php.net>\r
+All rights reserved.\r
+\r
+Redistribution and use in source and binary forms, with or without\r
+modification, are permitted provided that the following conditions\r
+are met:\r
+\r
+  1. Redistributions of source code must retain the above copyright\r
+     notice, this list of conditions and the following disclaimer.\r
+\r
+  2. Redistributions in binary form must reproduce the above copyright\r
+     notice, this list of conditions and the following disclaimer in the\r
+     documentation and/or other materials provided with the distribution.\r
+\r
+  3. Neither the name of Alexey Borzov nor the names of his contributors\r
+     may be used to endorse or promote products derived from this software\r
+     without specific prior written permission.\r
+\r
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\r
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\r
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\r
+LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\r
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\r
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\r
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\r
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\r
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF\r
+THE POSSIBILITY OF SUCH DAMAGE.\r