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