Projects
home:sicherha:branches:Kolab:16
php-pear-HTTP-Request2
Log In
Username
Password
We truncated the diff of some files because they were too big. If you want to see the full diff for every file,
click here
.
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
Expand all
Collapse all
Changes of Revision 4
View file
php-pear-HTTP-Request2.spec
Changed
@@ -28,7 +28,7 @@ %else Name: php-pear-HTTP-Request2 %endif -Version: 2.3.0 +Version: 2.6.0 Release: 1%{?dist} Summary: Provides an easy way to perform HTTP requests @@ -149,6 +149,9 @@ %changelog +* Tue Jul 09 2024 Christoph Erhardt <kolab@sicherha.de> - 2.6.0-1 +- Update to 2.6.0 + * Sun Feb 14 2016 Remi Collet <remi@fedoraproject.org> - 2.3.0-1 - update to 2.3.0 (stable) - raise dependency on Net_URL2 >= 2.2.0
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2.php
Deleted
@@ -1,1037 +0,0 @@ -<?php -/** - * Class representing a HTTP request message - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** - * A class representing an URL as per RFC 3986. - */ -if (!class_exists('Net_URL2', true)) { - require_once 'Net/URL2.php'; -} - -/** - * Exception class for HTTP_Request2 package - */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Class representing a HTTP request message - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc2616#section-5 - */ -class HTTP_Request2 implements SplSubject -{ - /**#@+ - * Constants for HTTP request methods - * - * @link http://tools.ietf.org/html/rfc2616#section-5.1.1 - */ - const METHOD_OPTIONS = 'OPTIONS'; - const METHOD_GET = 'GET'; - const METHOD_HEAD = 'HEAD'; - const METHOD_POST = 'POST'; - const METHOD_PUT = 'PUT'; - const METHOD_DELETE = 'DELETE'; - const METHOD_TRACE = 'TRACE'; - const METHOD_CONNECT = 'CONNECT'; - /**#@-*/ - - /**#@+ - * Constants for HTTP authentication schemes - * - * @link http://tools.ietf.org/html/rfc2617 - */ - const AUTH_BASIC = 'basic'; - const AUTH_DIGEST = 'digest'; - /**#@-*/ - - /** - * Regular expression used to check for invalid symbols in RFC 2616 tokens - * @link http://pear.php.net/bugs/bug.php?id=15630 - */ - const REGEXP_INVALID_TOKEN = '!\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\\?={}\s!'; - - /** - * Regular expression used to check for invalid symbols in cookie strings - * @link http://pear.php.net/bugs/bug.php?id=15630 - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html - */ - const REGEXP_INVALID_COOKIE = '/\s,;/'; - - /** - * Fileinfo magic database resource - * @var resource - * @see detectMimeType() - */ - private static $_fileinfoDb; - - /** - * Observers attached to the request (instances of SplObserver) - * @var array - */ - protected $observers = array(); - - /** - * Request URL - * @var Net_URL2 - */ - protected $url; - - /** - * Request method - * @var string - */ - protected $method = self::METHOD_GET; - - /** - * Authentication data - * @var array - * @see getAuth() - */ - protected $auth; - - /** - * Request headers - * @var array - */ - protected $headers = array(); - - /** - * Configuration parameters - * @var array - * @see setConfig() - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket', - 'connect_timeout' => 10, - 'timeout' => 0, - 'use_brackets' => true, - 'protocol_version' => '1.1', - 'buffer_size' => 16384, - 'store_body' => true, - 'local_ip' => null, - - 'proxy_host' => '', - 'proxy_port' => '', - 'proxy_user' => '', - 'proxy_password' => '', - 'proxy_auth_scheme' => self::AUTH_BASIC, - 'proxy_type' => 'http', - - 'ssl_verify_peer' => true, - 'ssl_verify_host' => true, - 'ssl_cafile' => null, - 'ssl_capath' => null, - 'ssl_local_cert' => null, - 'ssl_passphrase' => null, - - 'digest_compat_ie' => false, - - 'follow_redirects' => false, - 'max_redirects' => 5, - 'strict_redirects' => false - ); - - /** - * Last event in request / response handling, intended for observers - * @var array - * @see getLastEvent() - */ - protected $lastEvent = array( - 'name' => 'start', - 'data' => null - ); - - /** - * Request body - * @var string|resource - * @see setBody() - */ - protected $body = ''; - - /** - * Array of POST parameters - * @var array - */ - protected $postParams = array(); - - /** - * Array of file uploads (for multipart/form-data POST requests) - * @var array - */ - protected $uploads = array(); - - /** - * Adapter used to perform actual HTTP request - * @var HTTP_Request2_Adapter - */ - protected $adapter; - - /** - * Cookie jar to persist cookies between requests - * @var HTTP_Request2_CookieJar - */ - protected $cookieJar = null; - - /** - * Constructor. Can set request URL, method and configuration array.
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/Adapter.php
Deleted
@@ -1,137 +0,0 @@ -<?php -/** - * Base class for HTTP_Request2 adapters - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 response - */ -require_once 'HTTP/Request2/Response.php'; - -/** - * Base class for HTTP_Request2 adapters - * - * HTTP_Request2 class itself only defines methods for aggregating the request - * data, all actual work of sending the request to the remote server and - * receiving its response is performed by adapters. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - */ -abstract class HTTP_Request2_Adapter -{ - /** - * A list of methods that MUST NOT have a request body, per RFC 2616 - * @var array - */ - protected static $bodyDisallowed = array('TRACE'); - - /** - * Methods having defined semantics for request body - * - * Content-Length header (indicating that the body follows, section 4.3 of - * RFC 2616) will be sent for these methods even if no body was added - * - * @var array - * @link http://pear.php.net/bugs/bug.php?id=12900 - * @link http://pear.php.net/bugs/bug.php?id=14740 - */ - protected static $bodyRequired = array('POST', 'PUT'); - - /** - * Request being sent - * @var HTTP_Request2 - */ - protected $request; - - /** - * Request body - * @var string|resource|HTTP_Request2_MultipartBody - * @see HTTP_Request2::getBody() - */ - protected $requestBody; - - /** - * Length of the request body - * @var integer - */ - protected $contentLength; - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - abstract public function sendRequest(HTTP_Request2 $request); - - /** - * Calculates length of the request body, adds proper headers - * - * @param array &$headers associative array of request headers, this method - * will add proper 'Content-Length' and 'Content-Type' - * headers to this array (or remove them if not needed) - */ - protected function calculateRequestLength(&$headers) - { - $this->requestBody = $this->request->getBody(); - - if (is_string($this->requestBody)) { - $this->contentLength = strlen($this->requestBody); - } elseif (is_resource($this->requestBody)) { - $stat = fstat($this->requestBody); - $this->contentLength = $stat'size'; - rewind($this->requestBody); - } else { - $this->contentLength = $this->requestBody->getLength(); - $headers'content-type' = 'multipart/form-data; boundary=' . - $this->requestBody->getBoundary(); - $this->requestBody->rewind(); - } - - if (in_array($this->request->getMethod(), self::$bodyDisallowed) - || 0 == $this->contentLength - ) { - // No body: send a Content-Length header nonetheless (request #12900), - // but do that only for methods that require a body (bug #14740) - if (in_array($this->request->getMethod(), self::$bodyRequired)) { - $headers'content-length' = 0; - } else { - unset($headers'content-length'); - // if the method doesn't require a body and doesn't have a - // body, don't send a Content-Type header. (request #16799) - unset($headers'content-type'); - } - } else { - if (empty($headers'content-type')) { - $headers'content-type' = 'application/x-www-form-urlencoded'; - } - // Content-Length should not be sent for chunked Transfer-Encoding (bug #20125) - if (!isset($headers'transfer-encoding')) { - $headers'content-length' = $this->contentLength; - } - } - } -} -?>
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/Adapter/Curl.php
Deleted
@@ -1,577 +0,0 @@ -<?php -/** - * Adapter for HTTP_Request2 wrapping around cURL extension - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Adapter for HTTP_Request2 wrapping around cURL extension - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter -{ - /** - * Mapping of header names to cURL options - * @var array - */ - protected static $headerMap = array( - 'accept-encoding' => CURLOPT_ENCODING, - 'cookie' => CURLOPT_COOKIE, - 'referer' => CURLOPT_REFERER, - 'user-agent' => CURLOPT_USERAGENT - ); - - /** - * Mapping of SSL context options to cURL options - * @var array - */ - protected static $sslContextMap = array( - 'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER, - 'ssl_cafile' => CURLOPT_CAINFO, - 'ssl_capath' => CURLOPT_CAPATH, - 'ssl_local_cert' => CURLOPT_SSLCERT, - 'ssl_passphrase' => CURLOPT_SSLCERTPASSWD - ); - - /** - * Mapping of CURLE_* constants to Exception subclasses and error codes - * @var array - */ - protected static $errorMap = array( - CURLE_UNSUPPORTED_PROTOCOL => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_COULDNT_RESOLVE_PROXY => array('HTTP_Request2_ConnectionException'), - CURLE_COULDNT_RESOLVE_HOST => array('HTTP_Request2_ConnectionException'), - CURLE_COULDNT_CONNECT => array('HTTP_Request2_ConnectionException'), - // error returned from write callback - CURLE_WRITE_ERROR => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_OPERATION_TIMEOUTED => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::TIMEOUT), - CURLE_HTTP_RANGE_ERROR => array('HTTP_Request2_MessageException'), - CURLE_SSL_CONNECT_ERROR => array('HTTP_Request2_ConnectionException'), - CURLE_LIBRARY_NOT_FOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_FUNCTION_NOT_FOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_ABORTED_BY_CALLBACK => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::NON_HTTP_REDIRECT), - CURLE_TOO_MANY_REDIRECTS => array('HTTP_Request2_MessageException', - HTTP_Request2_Exception::TOO_MANY_REDIRECTS), - CURLE_SSL_PEER_CERTIFICATE => array('HTTP_Request2_ConnectionException'), - CURLE_GOT_NOTHING => array('HTTP_Request2_MessageException'), - CURLE_SSL_ENGINE_NOTFOUND => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_SSL_ENGINE_SETFAILED => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::MISCONFIGURATION), - CURLE_SEND_ERROR => array('HTTP_Request2_MessageException'), - CURLE_RECV_ERROR => array('HTTP_Request2_MessageException'), - CURLE_SSL_CERTPROBLEM => array('HTTP_Request2_LogicException', - HTTP_Request2_Exception::INVALID_ARGUMENT), - CURLE_SSL_CIPHER => array('HTTP_Request2_ConnectionException'), - CURLE_SSL_CACERT => array('HTTP_Request2_ConnectionException'), - CURLE_BAD_CONTENT_ENCODING => array('HTTP_Request2_MessageException'), - ); - - /** - * Response being received - * @var HTTP_Request2_Response - */ - protected $response; - - /** - * Whether 'sentHeaders' event was sent to observers - * @var boolean - */ - protected $eventSentHeaders = false; - - /** - * Whether 'receivedHeaders' event was sent to observers - * @var boolean - */ - protected $eventReceivedHeaders = false; - - /** - * Whether 'sentBoody' event was sent to observers - * @var boolean - */ - protected $eventSentBody = false; - - /** - * Position within request body - * @var integer - * @see callbackReadBody() - */ - protected $position = 0; - - /** - * Information about last transfer, as returned by curl_getinfo() - * @var array - */ - protected $lastInfo; - - /** - * Creates a subclass of HTTP_Request2_Exception from curl error data - * - * @param resource $ch curl handle - * - * @return HTTP_Request2_Exception - */ - protected static function wrapCurlError($ch) - { - $nativeCode = curl_errno($ch); - $message = 'Curl error: ' . curl_error($ch); - if (!isset(self::$errorMap$nativeCode)) { - return new HTTP_Request2_Exception($message, 0, $nativeCode); - } else { - $class = self::$errorMap$nativeCode0; - $code = empty(self::$errorMap$nativeCode1) - ? 0 : self::$errorMap$nativeCode1; - return new $class($message, $code, $nativeCode); - } - } - - /** - * Sends request to the remote server and returns its response - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - if (!extension_loaded('curl')) { - throw new HTTP_Request2_LogicException( - 'cURL extension not available', HTTP_Request2_Exception::MISCONFIGURATION - ); - } - - $this->request = $request; - $this->response = null; - $this->position = 0; - $this->eventSentHeaders = false; - $this->eventReceivedHeaders = false; - $this->eventSentBody = false; - - try { - if (false === curl_exec($ch = $this->createCurlHandle())) { - $e = self::wrapCurlError($ch); - } - } catch (Exception $e) { - } - if (isset($ch)) { - $this->lastInfo = curl_getinfo($ch); - if (CURLE_OK !== curl_errno($ch)) { - $this->request->setLastEvent('warning', curl_error($ch)); - } - curl_close($ch); - } - - $response = $this->response; - unset($this->request, $this->requestBody, $this->response); - - if (!empty($e)) {
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/Adapter/Mock.php
Deleted
@@ -1,166 +0,0 @@ -<?php -/** - * Mock adapter intended for testing - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ -require_once 'HTTP/Request2/Adapter.php'; - -/** - * Mock adapter intended for testing - * - * Can be used to test applications depending on HTTP_Request2 package without - * actually performing any HTTP requests. This adapter will return responses - * previously added via addResponse() - * <code> - * $mock = new HTTP_Request2_Adapter_Mock(); - * $mock->addResponse("HTTP/1.1 ... "); - * - * $request = new HTTP_Request2(); - * $request->setAdapter($mock); - * - * // This will return the response set above - * $response = $req->send(); - * </code> - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter -{ - /** - * A queue of responses to be returned by sendRequest() - * @var array - */ - protected $responses = array(); - - /** - * Returns the next response from the queue built by addResponse() - * - * Only responses without explicit URLs or with URLs equal to request URL - * will be considered. If matching response is not found or the queue is - * empty then default empty response with status 400 will be returned, - * if an Exception object was added to the queue it will be thrown. - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $requestUrl = (string)$request->getUrl(); - $response = null; - foreach ($this->responses as $k => $v) { - if (!$v1 || $requestUrl == $v1) { - $response = $v0; - array_splice($this->responses, $k, 1); - break; - } - } - if (!$response) { - return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n"); - - } elseif ($response instanceof HTTP_Request2_Response) { - return $response; - - } else { - // rethrow the exception - $class = get_class($response); - $message = $response->getMessage(); - $code = $response->getCode(); - throw new $class($message, $code); - } - } - - /** - * Adds response to the queue - * - * @param mixed $response either a string, a pointer to an open file, - * an instance of HTTP_Request2_Response or Exception - * @param string $url A request URL this response should be valid for - * (see {@link http://pear.php.net/bugs/bug.php?id=19276}) - * - * @throws HTTP_Request2_Exception - */ - public function addResponse($response, $url = null) - { - if (is_string($response)) { - $response = self::createResponseFromString($response); - } elseif (is_resource($response)) { - $response = self::createResponseFromFile($response); - } elseif (!$response instanceof HTTP_Request2_Response && - !$response instanceof Exception - ) { - throw new HTTP_Request2_Exception('Parameter is not a valid response'); - } - $this->responses = array($response, $url); - } - - /** - * Creates a new HTTP_Request2_Response object from a string - * - * @param string $str string containing HTTP response message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromString($str) - { - $parts = preg_split('!(\r?\n){2}!m', $str, 2); - $headerLines = explode("\n", $parts0); - $response = new HTTP_Request2_Response(array_shift($headerLines)); - foreach ($headerLines as $headerLine) { - $response->parseHeaderLine($headerLine); - } - $response->parseHeaderLine(''); - if (isset($parts1)) { - $response->appendBody($parts1); - } - return $response; - } - - /** - * Creates a new HTTP_Request2_Response object from a file - * - * @param resource $fp file pointer returned by fopen() - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public static function createResponseFromFile($fp) - { - $response = new HTTP_Request2_Response(fgets($fp)); - do { - $headerLine = fgets($fp); - $response->parseHeaderLine($headerLine); - } while ('' != trim($headerLine)); - - while (!feof($fp)) { - $response->appendBody(fread($fp, 8192)); - } - return $response; - } -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/Adapter/Socket.php
Deleted
@@ -1,1138 +0,0 @@ -<?php -/** - * Socket-based adapter for HTTP_Request2 - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 */ -require_once 'HTTP/Request2/Adapter.php'; - -/** Socket wrapper class */ -require_once 'HTTP/Request2/SocketWrapper.php'; - -/** - * Socket-based adapter for HTTP_Request2 - * - * This adapter uses only PHP sockets and will work on almost any PHP - * environment. Code is based on original HTTP_Request PEAR package. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter -{ - /** - * Regular expression for 'token' rule from RFC 2616 - */ - const REGEXP_TOKEN = '^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\\?={}\s+'; - - /** - * Regular expression for 'quoted-string' rule from RFC 2616 - */ - const REGEXP_QUOTED_STRING = '"(?>^"\\\\+|\\\\.)*"'; - - /** - * Connected sockets, needed for Keep-Alive support - * @var array - * @see connect() - */ - protected static $sockets = array(); - - /** - * Data for digest authentication scheme - * - * The keys for the array are URL prefixes. - * - * The values are associative arrays with data (realm, nonce, nonce-count, - * opaque...) needed for digest authentication. Stored here to prevent making - * duplicate requests to digest-protected resources after we have already - * received the challenge. - * - * @var array - */ - protected static $challenges = array(); - - /** - * Connected socket - * @var HTTP_Request2_SocketWrapper - * @see connect() - */ - protected $socket; - - /** - * Challenge used for server digest authentication - * @var array - */ - protected $serverChallenge; - - /** - * Challenge used for proxy digest authentication - * @var array - */ - protected $proxyChallenge; - - /** - * Remaining length of the current chunk, when reading chunked response - * @var integer - * @see readChunked() - */ - protected $chunkLength = 0; - - /** - * Remaining amount of redirections to follow - * - * Starts at 'max_redirects' configuration parameter and is reduced on each - * subsequent redirect. An Exception will be thrown once it reaches zero. - * - * @var integer - */ - 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 - * - * @param HTTP_Request2 $request HTTP request message - * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception - */ - public function sendRequest(HTTP_Request2 $request) - { - $this->request = $request; - - try { - $keepAlive = $this->connect(); - $headers = $this->prepareHeaders(); - $this->socket->write($headers); - // provide request headers to the observer, see request #7633 - $this->request->setLastEvent('sentHeaders', $headers); - - 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); - } - - if (!$this->canKeepAlive($keepAlive, $response)) { - $this->disconnect(); - } - - if ($this->shouldUseProxyDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($this->shouldUseServerDigestAuth($response)) { - return $this->sendRequest($request); - } - if ($authInfo = $response->getHeader('authentication-info')) { - $this->updateChallenge($this->serverChallenge, $authInfo); - } - if ($proxyInfo = $response->getHeader('proxy-authentication-info')) { - $this->updateChallenge($this->proxyChallenge, $proxyInfo); - } - - } catch (Exception $e) { - $this->disconnect(); - } - - unset($this->request, $this->requestBody); - - if (!empty($e)) { - $this->redirectCountdown = null; - throw $e; - } - - if (!$request->getConfig('follow_redirects') || !$response->isRedirect()) { - $this->redirectCountdown = null; - return $response; - } else { - return $this->handleRedirect($request, $response); - } - } - - /** - * Connects to the remote server - * - * @return bool whether the connection can be persistent - * @throws HTTP_Request2_Exception - */ - protected function connect() - { - $secure = 0 == strcasecmp($this->request->getUrl()->getScheme(), 'https'); - $tunnel = HTTP_Request2::METHOD_CONNECT == $this->request->getMethod(); - $headers = $this->request->getHeaders();
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/CookieJar.php
Deleted
@@ -1,547 +0,0 @@ -<?php -/** - * Stores cookies and passes them between HTTP requests - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 */ -require_once 'HTTP/Request2.php'; - -/** - * Stores cookies and passes them between HTTP requests - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: @package_version@ - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_CookieJar implements Serializable -{ - /** - * Array of stored cookies - * - * The array is indexed by domain, path and cookie name - * .example.com - * / - * some_cookie => cookie data - * /subdir - * other_cookie => cookie data - * .example.org - * ... - * - * @var array - */ - protected $cookies = array(); - - /** - * Whether session cookies should be serialized when serializing the jar - * @var bool - */ - protected $serializeSession = false; - - /** - * Whether Public Suffix List should be used for domain matching - * @var bool - */ - protected $useList = true; - - /** - * Whether an attempt to store an invalid cookie should be ignored, rather than cause an Exception - * @var bool - */ - protected $ignoreInvalid = false; - - /** - * Array with Public Suffix List data - * @var array - * @link http://publicsuffix.org/ - */ - protected static $psl = array(); - - /** - * Class constructor, sets various options - * - * @param bool $serializeSessionCookies Controls serializing session cookies, - * see {@link serializeSessionCookies()} - * @param bool $usePublicSuffixList Controls using Public Suffix List, - * see {@link usePublicSuffixList()} - * @param bool $ignoreInvalidCookies Whether invalid cookies should be ignored, - * see {@link ignoreInvalidCookies()} - */ - public function __construct( - $serializeSessionCookies = false, $usePublicSuffixList = true, - $ignoreInvalidCookies = false - ) { - $this->serializeSessionCookies($serializeSessionCookies); - $this->usePublicSuffixList($usePublicSuffixList); - $this->ignoreInvalidCookies($ignoreInvalidCookies); - } - - /** - * Returns current time formatted in ISO-8601 at UTC timezone - * - * @return string - */ - protected function now() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - return $dt->format(DateTime::ISO8601); - } - - /** - * Checks cookie array for correctness, possibly updating its 'domain', 'path' and 'expires' fields - * - * The checks are as follows: - * - cookie array should contain 'name' and 'value' fields; - * - name and value should not contain disallowed symbols; - * - 'expires' should be either empty parseable by DateTime; - * - 'domain' and 'path' should be either not empty or an URL where - * cookie was set should be provided. - * - if $setter is provided, then document at that URL should be allowed - * to set a cookie for that 'domain'. If $setter is not provided, - * then no domain checks will be made. - * - * 'expires' field will be converted to ISO8601 format from COOKIE format, - * 'domain' and 'path' will be set from setter URL if empty. - * - * @param array $cookie cookie data, as returned by - * {@link HTTP_Request2_Response::getCookies()} - * @param Net_URL2 $setter URL of the document that sent Set-Cookie header - * - * @return array Updated cookie array - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_MessageException - */ - protected function checkAndUpdateFields(array $cookie, Net_URL2 $setter = null) - { - if ($missing = array_diff(array('name', 'value'), array_keys($cookie))) { - throw new HTTP_Request2_LogicException( - "Cookie array should contain 'name' and 'value' fields", - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie'name')) { - throw new HTTP_Request2_LogicException( - "Invalid cookie name: '{$cookie'name'}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie'value')) { - throw new HTTP_Request2_LogicException( - "Invalid cookie value: '{$cookie'value'}'", - HTTP_Request2_Exception::INVALID_ARGUMENT - ); - } - $cookie += array('domain' => '', 'path' => '', 'expires' => null, 'secure' => false); - - // Need ISO-8601 date @ UTC timezone - if (!empty($cookie'expires') - && !preg_match('/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+0000$/', $cookie'expires') - ) { - try { - $dt = new DateTime($cookie'expires'); - $dt->setTimezone(new DateTimeZone('UTC')); - $cookie'expires' = $dt->format(DateTime::ISO8601); - } catch (Exception $e) { - throw new HTTP_Request2_LogicException($e->getMessage()); - } - } - - if (empty($cookie'domain') || empty($cookie'path')) { - if (!$setter) { - throw new HTTP_Request2_LogicException( - 'Cookie misses domain and/or path component, cookie setter URL needed', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - if (empty($cookie'domain')) { - if ($host = $setter->getHost()) { - $cookie'domain' = $host; - } else { - throw new HTTP_Request2_LogicException( - 'Setter URL does not contain host part, can\'t set cookie domain', - HTTP_Request2_Exception::MISSING_VALUE - ); - } - } - if (empty($cookie'path')) { - $path = $setter->getPath(); - $cookie'path' = empty($path)? '/': substr($path, 0, strrpos($path, '/') + 1); - } - } - - if ($setter && !$this->domainMatch($setter->getHost(), $cookie'domain')) { - throw new HTTP_Request2_MessageException( - "Domain " . $setter->getHost() . " cannot set cookies for " - . $cookie'domain' - ); - } - - return $cookie; - } -
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/Exception.php
Deleted
@@ -1,160 +0,0 @@ -<?php -/** - * Exception classes for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 exceptions in PEAR - */ -require_once 'PEAR/Exception.php'; - -/** - * Base exception class for HTTP_Request2 package - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=132 - */ -class HTTP_Request2_Exception extends PEAR_Exception -{ - /** An invalid argument was passed to a method */ - const INVALID_ARGUMENT = 1; - /** Some required value was not available */ - const MISSING_VALUE = 2; - /** Request cannot be processed due to errors in PHP configuration */ - const MISCONFIGURATION = 3; - /** Error reading the local file */ - const READ_ERROR = 4; - - /** Server returned a response that does not conform to HTTP protocol */ - const MALFORMED_RESPONSE = 10; - /** Failure decoding Content-Encoding or Transfer-Encoding of response */ - const DECODE_ERROR = 20; - /** Operation timed out */ - const TIMEOUT = 30; - /** Number of redirects exceeded 'max_redirects' configuration parameter */ - const TOO_MANY_REDIRECTS = 40; - /** Redirect to a protocol other than http(s):// */ - const NON_HTTP_REDIRECT = 50; - - /** - * Native error code - * @var int - */ - private $_nativeCode; - - /** - * Constructor, can set package error code and native error code - * - * @param string $message exception message - * @param int $code package error code, one of class constants - * @param int $nativeCode error code from underlying PHP extension - */ - public function __construct($message = null, $code = null, $nativeCode = null) - { - parent::__construct($message, $code); - $this->_nativeCode = $nativeCode; - } - - /** - * Returns error code produced by underlying PHP extension - * - * For Socket Adapter this may contain error number returned by - * stream_socket_client(), for Curl Adapter this will contain error number - * returned by curl_errno() - * - * @return integer - */ - public function getNativeCode() - { - return $this->_nativeCode; - } -} - -/** - * Exception thrown in case of missing features - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception -{ -} - -/** - * Exception that represents error in the program logic - * - * This exception usually implies a programmer's error, like passing invalid - * data to methods or trying to use PHP extensions that weren't installed or - * enabled. Usually exceptions of this kind will be thrown before request even - * starts. - * - * The exception will usually contain a package error code. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_LogicException extends HTTP_Request2_Exception -{ -} - -/** - * Exception thrown when connection to a web or proxy server fails - * - * The exception will not contain a package error code, but will contain - * native error code, as returned by stream_socket_client() or curl_errno(). - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception -{ -} - -/** - * Exception thrown when sending or receiving HTTP message fails - * - * The exception may contain both package error code and native error code. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_MessageException extends HTTP_Request2_Exception -{ -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/MultipartBody.php
Deleted
@@ -1,268 +0,0 @@ -<?php -/** - * Helper class for building multipart/form-data request body - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - * - * The class helps to reduce memory consumption by streaming large file uploads - * from disk, it also allows monitoring of upload progress (see request #7630) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc1867 - */ -class HTTP_Request2_MultipartBody -{ - /** - * MIME boundary - * @var string - */ - private $_boundary; - - /** - * Form parameters added via {@link HTTP_Request2::addPostParameter()} - * @var array - */ - private $_params = array(); - - /** - * File uploads added via {@link HTTP_Request2::addUpload()} - * @var array - */ - private $_uploads = array(); - - /** - * Header for parts with parameters - * @var string - */ - private $_headerParam = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n"; - - /** - * Header for parts with uploads - * @var string - */ - private $_headerUpload = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\nContent-Type: %s\r\n\r\n"; - - /** - * Current position in parameter and upload arrays - * - * First number is index of "current" part, second number is position within - * "current" part - * - * @var array - */ - private $_pos = array(0, 0); - - - /** - * Constructor. Sets the arrays with POST data. - * - * @param array $params values of form fields set via - * {@link HTTP_Request2::addPostParameter()} - * @param array $uploads file uploads set via - * {@link HTTP_Request2::addUpload()} - * @param bool $useBrackets whether to append brackets to array variable names - */ - public function __construct(array $params, array $uploads, $useBrackets = true) - { - $this->_params = self::_flattenArray('', $params, $useBrackets); - foreach ($uploads as $fieldName => $f) { - if (!is_array($f'fp')) { - $this->_uploads = $f + array('name' => $fieldName); - } else { - for ($i = 0; $i < count($f'fp'); $i++) { - $upload = array( - 'name' => ($useBrackets? $fieldName . '' . $i . '': $fieldName) - ); - foreach (array('fp', 'filename', 'size', 'type') as $key) { - $upload$key = $f$key$i; - } - $this->_uploads = $upload; - } - } - } - } - - /** - * Returns the length of the body to use in Content-Length header - * - * @return integer - */ - public function getLength() - { - $boundaryLength = strlen($this->getBoundary()); - $headerParamLength = strlen($this->_headerParam) - 4 + $boundaryLength; - $headerUploadLength = strlen($this->_headerUpload) - 8 + $boundaryLength; - $length = $boundaryLength + 6; - foreach ($this->_params as $p) { - $length += $headerParamLength + strlen($p0) + strlen($p1) + 2; - } - foreach ($this->_uploads as $u) { - $length += $headerUploadLength + strlen($u'name') + strlen($u'type') + - strlen($u'filename') + $u'size' + 2; - } - return $length; - } - - /** - * Returns the boundary to use in Content-Type header - * - * @return string - */ - public function getBoundary() - { - if (empty($this->_boundary)) { - $this->_boundary = '--' . md5('PEAR-HTTP_Request2-' . microtime()); - } - return $this->_boundary; - } - - /** - * Returns next chunk of request body - * - * @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) - { - $ret = ''; - $boundary = $this->getBoundary(); - $paramCount = count($this->_params); - $uploadCount = count($this->_uploads); - while ($length > 0 && $this->_pos0 <= $paramCount + $uploadCount) { - $oldLength = $length; - if ($this->_pos0 < $paramCount) { - $param = sprintf( - $this->_headerParam, $boundary, $this->_params$this->_pos00 - ) . $this->_params$this->_pos01 . "\r\n"; - $ret .= substr($param, $this->_pos1, $length); - $length -= min(strlen($param) - $this->_pos1, $length); - - } elseif ($this->_pos0 < $paramCount + $uploadCount) { - $pos = $this->_pos0 - $paramCount; - $header = sprintf( - $this->_headerUpload, $boundary, $this->_uploads$pos'name', - $this->_uploads$pos'filename', $this->_uploads$pos'type' - ); - if ($this->_pos1 < strlen($header)) { - $ret .= substr($header, $this->_pos1, $length); - $length -= min(strlen($header) - $this->_pos1, $length); - } - $filePos = max(0, $this->_pos1 - strlen($header)); - 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->_pos1 + ($oldLength - $length) - - strlen($header) - $this->_uploads$pos'size'; - $ret .= substr("\r\n", $start, $length); - $length -= min(2 - $start, $length); - } - - } else { - $closing = '--' . $boundary . "--\r\n"; - $ret .= substr($closing, $this->_pos1, $length); - $length -= min(strlen($closing) - $this->_pos1, $length);
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/Observer/Log.php
Deleted
@@ -1,192 +0,0 @@ -<?php -/** - * An observer useful for debugging / testing. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author David Jean Louis <izi@php.net> - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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'; - -/** - * A debug observer useful for debugging / testing. - * - * This observer logs to a log target data corresponding to the various request - * and response events, it logs by default to php://output but can be configured - * to log to a file or via the PEAR Log package. - * - * A simple example: - * <code> - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * $observer = new HTTP_Request2_Observer_Log(); - * $request->attach($observer); - * $request->send(); - * </code> - * - * A more complex example with PEAR Log: - * <code> - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/Log.php'; - * require_once 'Log.php'; - * - * $request = new HTTP_Request2('http://www.example.com'); - * // we want to log with PEAR log - * $observer = new HTTP_Request2_Observer_Log(Log::factory('console')); - * - * // we only want to log received headers - * $observer->events = array('receivedHeaders'); - * - * $request->attach($observer); - * $request->send(); - * </code> - * - * @category HTTP - * @package HTTP_Request2 - * @author David Jean Louis <izi@php.net> - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Observer_Log implements SplObserver -{ - // properties {{{ - - /** - * The log target, it can be a a resource or a PEAR Log instance. - * - * @var resource|Log $target - */ - protected $target = null; - - /** - * The events to log. - * - * @var array $events - */ - public $events = array( - 'connect', - 'sentHeaders', - 'sentBody', - 'receivedHeaders', - 'receivedBody', - 'disconnect', - ); - - // }}} - // __construct() {{{ - - /** - * Constructor. - * - * @param mixed $target Can be a file path (default: php://output), a resource, - * or an instance of the PEAR Log class. - * @param array $events Array of events to listen to (default: all events) - * - * @return void - */ - public function __construct($target = 'php://output', array $events = array()) - { - if (!empty($events)) { - $this->events = $events; - } - if (is_resource($target) || $target instanceof Log) { - $this->target = $target; - } elseif (false === ($this->target = @fopen($target, 'ab'))) { - throw new HTTP_Request2_Exception("Unable to open '{$target}'"); - } - } - - // }}} - // update() {{{ - - /** - * Called when the request notifies us of an event. - * - * @param HTTP_Request2 $subject The HTTP_Request2 instance - * - * @return void - */ - public function update(SplSubject $subject) - { - $event = $subject->getLastEvent(); - if (!in_array($event'name', $this->events)) { - return; - } - - switch ($event'name') { - case 'connect': - $this->log('* Connected to ' . $event'data'); - break; - case 'sentHeaders': - $headers = explode("\r\n", $event'data'); - array_pop($headers); - foreach ($headers as $header) { - $this->log('> ' . $header); - } - break; - case 'sentBody': - $this->log('> ' . $event'data' . ' byte(s) sent'); - break; - case 'receivedHeaders': - $this->log(sprintf( - '< HTTP/%s %s %s', $event'data'->getVersion(), - $event'data'->getStatus(), $event'data'->getReasonPhrase() - )); - $headers = $event'data'->getHeader(); - foreach ($headers as $key => $val) { - $this->log('< ' . $key . ': ' . $val); - } - $this->log('< '); - break; - case 'receivedBody': - $this->log($event'data'->getBody()); - break; - case 'disconnect': - $this->log('* Disconnected'); - break; - } - } - - // }}} - // log() {{{ - - /** - * Logs the given message to the configured target. - * - * @param string $message Message to display - * - * @return void - */ - protected function log($message) - { - if ($this->target instanceof Log) { - $this->target->debug($message); - } elseif (is_resource($this->target)) { - fwrite($this->target, $message . "\r\n"); - } - } - - // }}} -} - -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/Observer/UncompressingDownload.php
Deleted
@@ -1,265 +0,0 @@ -<?php -/** - * An observer that saves response body to stream, possibly uncompressing it - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Delian Krustev <krustev@krustev.net> - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -require_once 'HTTP/Request2/Response.php'; - -/** - * An observer that saves response body to stream, possibly uncompressing it - * - * This Observer is written in compliment to pear's HTTP_Request2 in order to - * avoid reading the whole response body in memory. Instead it writes the body - * to a stream. If the body is transferred with content-encoding set to - * "deflate" or "gzip" it is decoded on the fly. - * - * The constructor accepts an already opened (for write) stream (file_descriptor). - * If the response is deflate/gzip encoded a "zlib.inflate" filter is applied - * to the stream. When the body has been read from the request and written to - * the stream ("receivedBody" event) the filter is removed from the stream. - * - * The "zlib.inflate" filter works fine with pure "deflate" encoding. It does - * not understand the "deflate+zlib" and "gzip" headers though, so they have to - * be removed prior to being passed to the stream. This is done in the "update" - * method. - * - * It is also possible to limit the size of written extracted bytes by passing - * "max_bytes" to the constructor. This is important because e.g. 1GB of - * zeroes take about a MB when compressed. - * - * Exceptions are being thrown if data could not be written to the stream or - * the written bytes have already exceeded the requested maximum. If the "gzip" - * header is malformed or could not be parsed an exception will be thrown too. - * - * Example usage follows: - * - * <code> - * require_once 'HTTP/Request2.php'; - * require_once 'HTTP/Request2/Observer/UncompressingDownload.php'; - * - * #$inPath = 'http://carsten.codimi.de/gzip.yaws/daniels.html'; - * #$inPath = 'http://carsten.codimi.de/gzip.yaws/daniels.html?deflate=on'; - * $inPath = 'http://carsten.codimi.de/gzip.yaws/daniels.html?deflate=on&zlib=on'; - * #$outPath = "/dev/null"; - * $outPath = "delme"; - * - * $stream = fopen($outPath, 'wb'); - * if (!$stream) { - * throw new Exception('fopen failed'); - * } - * - * $request = new HTTP_Request2( - * $inPath, - * HTTP_Request2::METHOD_GET, - * array( - * 'store_body' => false, - * 'connect_timeout' => 5, - * 'timeout' => 10, - * 'ssl_verify_peer' => true, - * 'ssl_verify_host' => true, - * 'ssl_cafile' => null, - * 'ssl_capath' => '/etc/ssl/certs', - * 'max_redirects' => 10, - * 'follow_redirects' => true, - * 'strict_redirects' => false - * ) - * ); - * - * $observer = new HTTP_Request2_Observer_UncompressingDownload($stream, 9999999); - * $request->attach($observer); - * - * $response = $request->send(); - * - * fclose($stream); - * echo "OK\n"; - * </code> - * - * @category HTTP - * @package HTTP_Request2 - * @author Delian Krustev <krustev@krustev.net> - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - */ -class HTTP_Request2_Observer_UncompressingDownload implements SplObserver -{ - /** - * The stream to write response body to - * @var resource - */ - private $_stream; - - /** - * zlib.inflate filter possibly added to stream - * @var resource - */ - private $_streamFilter; - - /** - * The value of response's Content-Encoding header - * @var string - */ - private $_encoding; - - /** - * Whether the observer is still waiting for gzip/deflate header - * @var bool - */ - private $_processingHeader = true; - - /** - * Starting position in the stream observer writes to - * @var int - */ - private $_startPosition = 0; - - /** - * Maximum bytes to write - * @var int|null - */ - private $_maxDownloadSize; - - /** - * Whether response being received is a redirect - * @var bool - */ - private $_redirect = false; - - /** - * Accumulated body chunks that may contain (gzip) header - * @var string - */ - private $_possibleHeader = ''; - - /** - * Class constructor - * - * Note that there might be problems with max_bytes and files bigger - * than 2 GB on 32bit platforms - * - * @param resource $stream a stream (or file descriptor) opened for writing. - * @param int $maxDownloadSize maximum bytes to write - */ - public function __construct($stream, $maxDownloadSize = null) - { - $this->_stream = $stream; - if ($maxDownloadSize) { - $this->_maxDownloadSize = $maxDownloadSize; - $this->_startPosition = ftell($this->_stream); - } - } - - /** - * Called when the request notifies us of an event. - * - * @param SplSubject $request The HTTP_Request2 instance - * - * @return void - * @throws HTTP_Request2_MessageException - */ - public function update(SplSubject $request) - { - /* @var $request HTTP_Request2 */ - $event = $request->getLastEvent(); - $encoded = false; - - /* @var $event'data' HTTP_Request2_Response */ - switch ($event'name') { - case 'receivedHeaders': - $this->_processingHeader = true; - $this->_redirect = $event'data'->isRedirect(); - $this->_encoding = strtolower($event'data'->getHeader('content-encoding')); - $this->_possibleHeader = ''; - break; - - case 'receivedEncodedBodyPart': - if (!$this->_streamFilter - && ($this->_encoding === 'deflate' || $this->_encoding === 'gzip') - ) { - $this->_streamFilter = stream_filter_append( - $this->_stream, 'zlib.inflate', STREAM_FILTER_WRITE - ); - }
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/Response.php
Deleted
@@ -1,680 +0,0 @@ -<?php -/** - * Class representing a HTTP response - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 representing a HTTP response - * - * The class is designed to be used in "streaming" scenario, building the - * response as it is being received: - * <code> - * $statusLine = read_status_line(); - * $response = new HTTP_Request2_Response($statusLine); - * do { - * $headerLine = read_header_line(); - * $response->parseHeaderLine($headerLine); - * } while ($headerLine != ''); - * - * while ($chunk = read_body()) { - * $response->appendBody($chunk); - * } - * - * var_dump($response->getHeader(), $response->getCookies(), $response->getBody()); - * </code> - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @link http://pear.php.net/package/HTTP_Request2 - * @link http://tools.ietf.org/html/rfc2616#section-6 - */ -class HTTP_Request2_Response -{ - /** - * HTTP protocol version (e.g. 1.0, 1.1) - * @var string - */ - protected $version; - - /** - * Status code - * @var integer - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $code; - - /** - * Reason phrase - * @var string - * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 - */ - protected $reasonPhrase; - - /** - * Effective URL (may be different from original request URL in case of redirects) - * @var string - */ - protected $effectiveUrl; - - /** - * Associative array of response headers - * @var array - */ - protected $headers = array(); - - /** - * Cookies set in the response - * @var array - */ - protected $cookies = array(); - - /** - * Name of last header processed by parseHederLine() - * - * Used to handle the headers that span multiple lines - * - * @var string - */ - protected $lastHeader = null; - - /** - * Response body - * @var string - */ - protected $body = ''; - - /** - * Whether the body is still encoded by Content-Encoding - * - * cURL provides the decoded body to the callback; if we are reading from - * socket the body is still gzipped / deflated - * - * @var bool - */ - protected $bodyEncoded; - - /** - * Associative array of HTTP status code / reason phrase. - * - * @var array - * @link http://tools.ietf.org/html/rfc2616#section-10 - */ - protected static $phrases = array( - - // 1xx: Informational - Request received, continuing process - 100 => 'Continue', - 101 => 'Switching Protocols', - - // 2xx: Success - The action was successfully received, understood and - // accepted - 200 => 'OK', - 201 => 'Created', - 202 => 'Accepted', - 203 => 'Non-Authoritative Information', - 204 => 'No Content', - 205 => 'Reset Content', - 206 => 'Partial Content', - - // 3xx: Redirection - Further action must be taken in order to complete - // the request - 300 => 'Multiple Choices', - 301 => 'Moved Permanently', - 302 => 'Found', // 1.1 - 303 => 'See Other', - 304 => 'Not Modified', - 305 => 'Use Proxy', - 307 => 'Temporary Redirect', - - // 4xx: Client Error - The request contains bad syntax or cannot be - // fulfilled - 400 => 'Bad Request', - 401 => 'Unauthorized', - 402 => 'Payment Required', - 403 => 'Forbidden', - 404 => 'Not Found', - 405 => 'Method Not Allowed', - 406 => 'Not Acceptable', - 407 => 'Proxy Authentication Required', - 408 => 'Request Timeout', - 409 => 'Conflict', - 410 => 'Gone', - 411 => 'Length Required', - 412 => 'Precondition Failed', - 413 => 'Request Entity Too Large', - 414 => 'Request-URI Too Long', - 415 => 'Unsupported Media Type', - 416 => 'Requested Range Not Satisfiable', - 417 => 'Expectation Failed', - - // 5xx: Server Error - The server failed to fulfill an apparently - // valid request - 500 => 'Internal Server Error', - 501 => 'Not Implemented', - 502 => 'Bad Gateway', - 503 => 'Service Unavailable', - 504 => 'Gateway Timeout', - 505 => 'HTTP Version Not Supported', - 509 => 'Bandwidth Limit Exceeded', - - ); - - /** - * Returns the default reason phrase for the given code or all reason phrases - * - * @param int $code Response code - * - * @return string|array|null Default reason phrase for $code if $code is given - * (null if no phrase is available), array of all - * reason phrases if $code is null - * @link http://pear.php.net/bugs/18716 - */ - public static function getDefaultReasonPhrase($code = null) - { - if (null === $code) { - return self::$phrases; - } else { - return isset(self::$phrases$code) ? self::$phrases$code : null;
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/SOCKS5.php
Deleted
@@ -1,135 +0,0 @@ -<?php -/** - * SOCKS5 proxy connection class - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 */ -require_once 'HTTP/Request2/SocketWrapper.php'; - -/** - * SOCKS5 proxy connection class (used by Socket Adapter) - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @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 - */ -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 $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 $contextOptions = array(), - $username = null, $password = null - ) { - parent::__construct($address, $timeout, $contextOptions); - - if (strlen($username)) { - $request = pack('C4', 5, 2, 0, 2); - } else { - $request = pack('C3', 5, 1, 0); - } - $this->write($request); - $response = unpack('Cversion/Cmethod', $this->read(3)); - if (5 != $response'version') { - throw new HTTP_Request2_MessageException( - 'Invalid version received from SOCKS5 proxy: ' . $response'version', - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } - switch ($response'method') { - case 2: - $this->performAuthentication($username, $password); - case 0: - break; - default: - throw new HTTP_Request2_ConnectionException( - "Connection rejected by proxy due to unsupported auth method" - ); - } - } - - /** - * Performs username/password authentication for SOCKS5 - * - * @param string $username Proxy user name - * @param string $password Proxy password - * - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - * @link http://tools.ietf.org/html/rfc1929 - */ - protected function performAuthentication($username, $password) - { - $request = pack('C2', 1, strlen($username)) . $username - . pack('C', strlen($password)) . $password; - - $this->write($request); - $response = unpack('Cvn/Cstatus', $this->read(3)); - if (1 != $response'vn' || 0 != $response'status') { - throw new HTTP_Request2_ConnectionException( - 'Connection rejected by proxy due to invalid username and/or password' - ); - } - } - - /** - * Connects to a remote host via proxy - * - * @param string $remoteHost Remote host - * @param int $remotePort Remote port - * - * @throws HTTP_Request2_ConnectionException - * @throws HTTP_Request2_MessageException - */ - public function connect($remoteHost, $remotePort) - { - $request = pack('C5', 0x05, 0x01, 0x00, 0x03, strlen($remoteHost)) - . $remoteHost . pack('n', $remotePort); - - $this->write($request); - $response = unpack('Cversion/Creply/Creserved', $this->read(1024)); - if (5 != $response'version' || 0 != $response'reserved') { - throw new HTTP_Request2_MessageException( - 'Invalid response received from SOCKS5 proxy', - HTTP_Request2_Exception::MALFORMED_RESPONSE - ); - } elseif (0 != $response'reply') { - throw new HTTP_Request2_ConnectionException( - "Unable to connect to {$remoteHost}:{$remotePort} through SOCKS5 proxy", - 0, $response'reply' - ); - } - } -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/HTTP/Request2/SocketWrapper.php
Deleted
@@ -1,320 +0,0 @@ -<?php -/** - * Socket wrapper class used by Socket Adapter - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 */ -require_once 'HTTP/Request2/Exception.php'; - -/** - * Socket wrapper class used by Socket Adapter - * - * Needed to properly handle connection errors, global timeout support and - * similar things. Loosely based on Net_Socket used by older HTTP_Request. - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.3.0 - * @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 - */ -class HTTP_Request2_SocketWrapper -{ - /** - * PHP warning messages raised during stream_socket_client() call - * @var array - */ - protected $connectionWarnings = array(); - - /** - * Connected socket - * @var resource - */ - protected $socket; - - /** - * Sum of start time and global timeout, exception will be thrown if request continues past this time - * @var integer - */ - protected $deadline; - - /** - * Global timeout value, mostly for exception messages - * @var integer - */ - protected $timeout; - - /** - * 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 $contextOptions Context options - * - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_ConnectionException - */ - 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); - } - if (isset($contextOptions'ssl')) { - $contextOptions'ssl' += array( - // Using "Intermediate compatibility" cipher bundle from - // https://wiki.mozilla.org/Security/Server_Side_TLS - 'ciphers' => 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:' - . 'ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:' - . 'DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:' - . 'ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:' - . 'ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:' - . 'ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:' - . 'ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:' - . 'DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:' - . 'DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:' - . 'ECDHE-RSA-DES-CBC3-SHA:ECDHE-ECDSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:' - . 'AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:' - . 'AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:' - . '!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA' - ); - if (version_compare(phpversion(), '5.4.13', '>=')) { - $contextOptions'ssl''disable_compression' = true; - if (version_compare(phpversion(), '5.6', '>=')) { - $contextOptions'ssl''crypto_method' = STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT - | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; - } - } - } - $context = stream_context_create(); - 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')); - $this->socket = stream_socket_client( - $address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context - ); - restore_error_handler(); - // 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 - ); - } - } - - /** - * Destructor, disconnects socket - */ - public function __destruct() - { - fclose($this->socket); - } - - /** - * Wrapper around fread(), handles global request timeout - * - * @param int $length Reads up to this number of bytes - * - * @return string Data read from socket - * @throws HTTP_Request2_MessageException In case of timeout - */ - public function read($length) - { - if ($this->deadline) { - stream_set_timeout($this->socket, max($this->deadline - time(), 1)); - } - $data = fread($this->socket, $length); - $this->checkTimeout(); - return $data; - } - - /** - * Reads until either the end of the socket or a newline, whichever comes first - * - * 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 $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, $localTimeout = null) - { - $line = ''; - while (!feof($this->socket)) { - 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); - - 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');
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/data/generate-list.php
Deleted
@@ -1,103 +0,0 @@ -<?php -/** - * Helper file for downloading Public Suffix List and converting it to PHP array - * - * You can run this script to update PSL to the current version instead of - * waiting for a new release of HTTP_Request2. - * - * NB: peer validation is DISABLED when downloading. If you want to enable it, - * change ssl_verify_peer to true and provide CA file (see below) - */ - -/** URL to download Public Suffix List from */ -define('LIST_URL', 'https://publicsuffix.org/list/public_suffix_list.dat'); -/** Name of PHP file to write */ -define('OUTPUT_FILE', dirname(__FILE__) . '/public-suffix-list.php'); - -require_once 'HTTP/Request2.php'; - -function buildSubdomain(&$node, $tldParts) -{ - $part = trim(array_pop($tldParts)); - - if (!array_key_exists($part, $node)) { - $node$part = array(); - } - - if (0 < count($tldParts)) { - buildSubdomain($node$part, $tldParts); - } -} - -function writeNode($fp, $valueTree, $key = null, $indent = 0) -{ - if (is_null($key)) { - fwrite($fp, "return "); - - } else { - fwrite($fp, str_repeat(' ', $indent) . "'$key' => "); - } - - if (0 == ($count = count($valueTree))) { - fwrite($fp, 'true'); - } else { - fwrite($fp, "array(\n"); - for ($keys = array_keys($valueTree), $i = 0; $i < $count; $i++) { - writeNode($fp, $valueTree$keys$i, $keys$i, $indent + 1); - if ($i + 1 != $count) { - fwrite($fp, ",\n"); - } else { - fwrite($fp, "\n"); - } - } - fwrite($fp, str_repeat(' ', $indent) . ")"); - } -} - - -try { - $request = new HTTP_Request2(LIST_URL, HTTP_Request2::METHOD_GET, array( - // Provide path to your CA file and change 'ssl_verify_peer' to true to enable peer validation - // 'ssl_cafile' => '... path to your Certificate Authority file ...', - 'ssl_verify_peer' => false - )); - $response = $request->send(); - if (200 != $response->getStatus()) { - throw new Exception("List download URL returned status: " . - $response->getStatus() . ' ' . $response->getReasonPhrase()); - } - $list = $response->getBody(); - if (false === strpos($list, '// ===BEGIN ICANN DOMAINS===')) { - throw new Exception("List download URL does not contain expected phrase"); - } - if (!($fp = @fopen(OUTPUT_FILE, 'wt'))) { - throw new Exception("Unable to open " . OUTPUT_FILE); - } - -} catch (Exception $e) { - die($e->getMessage()); -} - -$tldTree = array(); -$license = true; - -fwrite($fp, "<?php\n"); - -foreach (array_filter(array_map('trim', explode("\n", $list))) as $line) { - if ('//' != substr($line, 0, 2)) { - buildSubdomain($tldTree, explode('.', $line)); - - } elseif ($license) { - if (0 === strpos($line, "// ===BEGIN ICANN DOMAINS===")) { - fwrite($fp, "\n"); - $license = false; - } else { - fwrite($fp, $line . "\n"); - } - } -} - -writeNode($fp, $tldTree); -fwrite($fp, ";\n?>"); -fclose($fp); -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/data/public-suffix-list.php
Deleted
@@ -1,8333 +0,0 @@ -<?php -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -return array( - 'ac' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'net' => true, - 'mil' => true, - 'org' => true - ), - 'ad' => array( - 'nom' => true - ), - 'ae' => array( - 'co' => true, - 'net' => true, - 'org' => true, - 'sch' => true, - 'ac' => true, - 'gov' => true, - 'mil' => true, - 'blogspot' => true - ), - 'aero' => array( - 'accident-investigation' => true, - 'accident-prevention' => true, - 'aerobatic' => true, - 'aeroclub' => true, - 'aerodrome' => true, - 'agents' => true, - 'aircraft' => true, - 'airline' => true, - 'airport' => true, - 'air-surveillance' => true, - 'airtraffic' => true, - 'air-traffic-control' => true, - 'ambulance' => true, - 'amusement' => true, - 'association' => true, - 'author' => true, - 'ballooning' => true, - 'broker' => true, - 'caa' => true, - 'cargo' => true, - 'catering' => true, - 'certification' => true, - 'championship' => true, - 'charter' => true, - 'civilaviation' => true, - 'club' => true, - 'conference' => true, - 'consultant' => true, - 'consulting' => true, - 'control' => true, - 'council' => true, - 'crew' => true, - 'design' => true, - 'dgca' => true, - 'educator' => true, - 'emergency' => true, - 'engine' => true, - 'engineer' => true, - 'entertainment' => true, - 'equipment' => true, - 'exchange' => true, - 'express' => true, - 'federation' => true, - 'flight' => true, - 'freight' => true, - 'fuel' => true, - 'gliding' => true, - 'government' => true, - 'groundhandling' => true, - 'group' => true, - 'hanggliding' => true, - 'homebuilt' => true, - 'insurance' => true, - 'journal' => true, - 'journalist' => true, - 'leasing' => true, - 'logistics' => true, - 'magazine' => true, - 'maintenance' => true, - 'media' => true, - 'microlight' => true, - 'modelling' => true, - 'navigation' => true, - 'parachuting' => true, - 'paragliding' => true, - 'passenger-association' => true, - 'pilot' => true, - 'press' => true, - 'production' => true, - 'recreation' => true, - 'repbody' => true, - 'res' => true, - 'research' => true, - 'rotorcraft' => true, - 'safety' => true, - 'scientist' => true, - 'services' => true, - 'show' => true, - 'skydiving' => true, - 'software' => true, - 'student' => true, - 'trader' => true, - 'trading' => true, - 'trainer' => true, - 'union' => true, - 'workinggroup' => true, - 'works' => true - ), - 'af' => array( - 'gov' => true, - 'com' => true, - 'org' => true, - 'net' => true, - 'edu' => true - ), - 'ag' => array( - 'com' => true, - 'org' => true, - 'net' => true, - 'co' => true, - 'nom' => true - ), - 'ai' => array( - 'off' => true, - 'com' => true, - 'net' => true, - 'org' => true - ), - 'al' => array( - 'com' => true, - 'edu' => true, - 'gov' => true, - 'mil' => true, - 'net' => true, - 'org' => true, - 'blogspot' => true - ), - 'am' => array( - 'blogspot' => true - ), - 'ao' => array( - 'ed' => true, - 'gv' => true, - 'og' => true, - 'co' => true, - 'pb' => true, - 'it' => true - ), - 'aq' => true, - 'ar' => array( - 'com' => array( - 'blogspot' => true - ), - 'edu' => true, - 'gob' => true, - 'gov' => true, - 'int' => true, - 'mil' => true, - 'net' => true, - 'org' => true, - 'tur' => true - ), - 'arpa' => array( - 'e164' => true, - 'in-addr' => true, - 'ip6' => true, - 'iris' => true, - 'uri' => true, - 'urn' => true - ), - 'as' => array( - 'gov' => true - ), - 'asia' => true, - 'at' => array( - 'ac' => true, - 'co' => array( - 'blogspot' => true - ), - 'gv' => true, - 'or' => true, - 'biz' => true, - 'info' => true, - 'priv' => true - ), - 'au' => array( - 'com' => array( - 'blogspot' => true - ), - 'net' => true, - 'org' => true,
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/docs/LICENSE
Deleted
@@ -1,31 +0,0 @@ -HTTP_Request2 - -Copyright (c) 2008-2016, 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.
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/docs/examples/upload-rapidshare.php
Deleted
@@ -1,58 +0,0 @@ -<?php -/** - * Usage example for HTTP_Request2 package: uploading a file to rapidshare.com - * - * Inspired by Perl usage example: http://images.rapidshare.com/software/rsapi.pl - * Rapidshare API description: http://rapidshare.com/dev.html - */ - -require_once 'HTTP/Request2.php'; - -// You'll probably want to change this -$filename = '/etc/passwd'; - -try { - // First step: get an available upload server - $request = new HTTP_Request2( - 'http://rapidshare.com/cgi-bin/rsapi.cgi?sub=nextuploadserver_v1' - ); - $server = $request->send()->getBody(); - if (!preg_match('/^(\\d+)$/', $server)) { - throw new Exception("Invalid upload server: {$server}"); - } - - // Calculate file hash, we'll use it later to check upload - if (false === ($hash = @md5_file($filename))) { - throw new Exception("Cannot calculate MD5 hash of '{$filename}'"); - } - - // Second step: upload a file to the available server - $uploader = new HTTP_Request2( - "http://rs{$server}l3.rapidshare.com/cgi-bin/upload.cgi", - HTTP_Request2::METHOD_POST - ); - // Adding the file - $uploader->addUpload('filecontent', $filename); - // This will tell server to return program-friendly output - $uploader->addPostParameter('rsapi_v1', '1'); - - $response = $uploader->send()->getBody(); - if (!preg_match_all('/^(File^=+)=(.+)$/m', $response, $m, PREG_SET_ORDER)) { - throw new Exception("Invalid response: {$response}"); - } - $rspAry = array(); - foreach ($m as $item) { - $rspAry$item1 = $item2; - } - // Check that uploaded file has the same hash - if (empty($rspAry'File1.4')) { - throw new Exception("MD5 hash data not found in response"); - } elseif ($hash != strtolower($rspAry'File1.4')) { - throw new Exception("Upload failed, local MD5 is {$hash}, uploaded MD5 is {$rspAry'File1.4'}"); - } - echo "Upload succeeded\nDownload link: {$rspAry'File1.1'}\nDelete link: {$rspAry'File1.2'}\n"; - -} catch (Exception $e) { - echo "Error: " . $e->getMessage(); -} -?>
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/AllTests.php
Deleted
@@ -1,58 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - if (strpos($_SERVER'argv'0, 'phpunit') === false) { - define('PHPUnit_MAIN_METHOD', 'HTTP_Request2_AllTests::main'); - } else { - define('PHPUnit_MAIN_METHOD', false); - } -} - -require_once dirname(__FILE__) . '/Request2Test.php'; -require_once dirname(__FILE__) . '/ObserverTest.php'; -require_once dirname(__FILE__) . '/Request2/AllTests.php'; - -class HTTP_Request2_AllTests -{ - public static function main() - { - if (!class_exists('PHPUnit_TextUI_TestRunner', true)) { - require_once 'PHPUnit/TextUI/TestRunner.php'; - } - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package'); - - $suite->addTest(Request2_AllTests::suite()); - $suite->addTestSuite('HTTP_Request2Test'); - $suite->addTestSuite('HTTP_Request2_ObserverTest'); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'HTTP_Request2_AllTests::main') { - HTTP_Request2_AllTests::main(); -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/NetworkConfig.php.dist
Deleted
@@ -1,58 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** - * This file contains configuration needed for running HTTP_Request2 tests - * that interact with the network. Do not edit this file, copy it to - * NetworkConfig.php and edit the copy instead. - */ - -/** - * Base URL for HTTP_Request2 Adapters tests - * - * To enable the tests that actually perform network interaction, you should - * copy the contents of _network directory to a directory under your web - * server's document root or create a symbolic link to _network directory - * there. Set this constant to point to the URL of that directory. - */ -define('HTTP_REQUEST2_TESTS_BASE_URL', null); - -/** - * URL that is protected by server digest authentication - * - * This is needed for testing of 100 Continue handling, we can't implement - * digest in PHP since it will kick in a bit later - */ -define('HTTP_REQUEST2_TESTS_DIGEST_URL', null); - -/**#@+ - * Proxy setup for Socket Adapter tests - * - * Set these constants to run additional tests for Socket Adapter using a HTTP - * proxy. If proxy host is not set then the tests will not be run. - */ -define('HTTP_REQUEST2_TESTS_PROXY_HOST', null); -define('HTTP_REQUEST2_TESTS_PROXY_PORT', 8080); -define('HTTP_REQUEST2_TESTS_PROXY_USER', ''); -define('HTTP_REQUEST2_TESTS_PROXY_PASSWORD', ''); -define('HTTP_REQUEST2_TESTS_PROXY_AUTH_SCHEME', 'basic'); -define('HTTP_REQUEST2_TESTS_PROXY_TYPE', 'http'); -/**#@-*/ -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/ObserverTest.php
Deleted
@@ -1,95 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** Sets up includes */ -require_once dirname(__FILE__) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Mock observer - */ -class HTTP_Request2_MockObserver implements SplObserver -{ - public $calls = 0; - - public $event; - - public function update (SplSubject $subject) - { - $this->calls++; - $this->event = $subject->getLastEvent(); - } -} - -/** - * Unit test for subject-observer pattern implementation in HTTP_Request2 - */ -class HTTP_Request2_ObserverTest extends PHPUnit_Framework_TestCase -{ - public function testSetLastEvent() - { - $request = new HTTP_Request2(); - $observer = new HTTP_Request2_MockObserver(); - $request->attach($observer); - - $request->setLastEvent('foo', 'bar'); - $this->assertEquals(1, $observer->calls); - $this->assertEquals(array('name' => 'foo', 'data' => 'bar'), $observer->event); - - $request->setLastEvent('baz'); - $this->assertEquals(2, $observer->calls); - $this->assertEquals(array('name' => 'baz', 'data' => null), $observer->event); - } - - public function testAttachOnlyOnce() - { - $request = new HTTP_Request2(); - $observer = new HTTP_Request2_MockObserver(); - $observer2 = new HTTP_Request2_MockObserver(); - $request->attach($observer); - $request->attach($observer2); - $request->attach($observer); - - $request->setLastEvent('event', 'data'); - $this->assertEquals(1, $observer->calls); - $this->assertEquals(1, $observer2->calls); - } - - public function testDetach() - { - $request = new HTTP_Request2(); - $observer = new HTTP_Request2_MockObserver(); - $observer2 = new HTTP_Request2_MockObserver(); - - $request->attach($observer); - $request->detach($observer2); // should not be a error - $request->setLastEvent('first'); - - $request->detach($observer); - $request->setLastEvent('second'); - $this->assertEquals(1, $observer->calls); - $this->assertEquals(array('name' => 'first', 'data' => null), $observer->event); - } -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2/Adapter/AllTests.php
Deleted
@@ -1,77 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - if (strpos($_SERVER'argv'0, 'phpunit') === false) { - define('PHPUnit_MAIN_METHOD', 'Request2_Adapter_AllTests::main'); - } else { - define('PHPUnit_MAIN_METHOD', false); - } -} - -require_once dirname(__FILE__) . '/MockTest.php'; -require_once dirname(__FILE__) . '/SkippedTests.php'; -require_once dirname(__FILE__) . '/SocketTest.php'; -require_once dirname(__FILE__) . '/SocketProxyTest.php'; -require_once dirname(__FILE__) . '/CurlTest.php'; - -class Request2_Adapter_AllTests -{ - public static function main() - { - if (!class_exists('PHPUnit_TextUI_TestRunner', true)) { - require_once 'PHPUnit/TextUI/TestRunner.php'; - } - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package - Request2 - Adapter'); - - $suite->addTestSuite('HTTP_Request2_Adapter_MockTest'); - if (defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL) { - $suite->addTestSuite('HTTP_Request2_Adapter_SocketTest'); - } else { - $suite->addTestSuite('HTTP_Request2_Adapter_Skip_SocketTest'); - } - if (defined('HTTP_REQUEST2_TESTS_PROXY_HOST') && HTTP_REQUEST2_TESTS_PROXY_HOST - && defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL - ) { - $suite->addTestSuite('HTTP_Request2_Adapter_SocketProxyTest'); - } else { - $suite->addTestSuite('HTTP_Request2_Adapter_Skip_SocketProxyTest'); - } - if (defined('HTTP_REQUEST2_TESTS_BASE_URL') && HTTP_REQUEST2_TESTS_BASE_URL - && extension_loaded('curl') - ) { - $suite->addTestSuite('HTTP_Request2_Adapter_CurlTest'); - } else { - $suite->addTestSuite('HTTP_Request2_Adapter_Skip_CurlTest'); - } - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Request2_Adapter_AllTests::main') { - Request2_Adapter_AllTests::main(); -} -?>
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2/Adapter/CommonNetworkTest.php
Deleted
@@ -1,512 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** Sets up includes */ -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - -/** Class representing a HTTP request */ -require_once 'HTTP/Request2.php'; -/** Class for building multipart/form-data request body */ -require_once 'HTTP/Request2/MultipartBody.php'; -/** An observer that saves response body to stream, possibly uncompressing it */ -require_once 'HTTP/Request2/Observer/UncompressingDownload.php'; - -class SlowpokeBody extends HTTP_Request2_MultipartBody -{ - protected $doSleep; - - public function rewind() - { - $this->doSleep = true; - parent::rewind(); - } - - public function read($length) - { - if ($this->doSleep) { - sleep(3); - $this->doSleep = false; - } - return parent::read($length); - } -} - -class HeaderObserver implements SplObserver -{ - public $headers; - - public function update(SplSubject $subject) - { - /* @var $subject HTTP_Request2 */ - $event = $subject->getLastEvent(); - - // force a timeout when writing request body - if ('sentHeaders' == $event'name') { - $this->headers = $event'data'; - } - } -} - -class EventSequenceObserver implements SplObserver -{ - private $_watched = array(); - - public $sequence = array(); - - public function __construct(array $watchedEvents = array()) - { - if (!empty($watchedEvents)) { - $this->_watched = $watchedEvents; - } - } - - public function update(SplSubject $subject) - { - /* @var $subject HTTP_Request2 */ - $event = $subject->getLastEvent(); - - if ($event'name' !== end($this->sequence) - && (empty($this->_watched) || in_array($event'name', $this->_watched, true)) - ) { - $this->sequence = $event'name'; - } - } -} - - -/** - * Tests for HTTP_Request2 package that require a working webserver - * - * The class contains some common tests that should be run for all Adapters, - * it is extended by their unit tests. - * - * You need to properly set up this test suite, refer to NetworkConfig.php.dist - */ -abstract class HTTP_Request2_Adapter_CommonNetworkTest extends PHPUnit_Framework_TestCase -{ - /** - * HTTP Request object - * @var HTTP_Request2 - */ - protected $request; - - /** - * Base URL for remote test files - * @var string - */ - protected $baseUrl; - - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array(); - - protected function setUp() - { - if (!defined('HTTP_REQUEST2_TESTS_BASE_URL') || !HTTP_REQUEST2_TESTS_BASE_URL) { - $this->markTestSkipped('Base URL is not configured'); - - } else { - $this->baseUrl = rtrim(HTTP_REQUEST2_TESTS_BASE_URL, '/') . '/'; - $name = strtolower(preg_replace('/^test/i', '', $this->getName())) . '.php'; - - $this->request = new HTTP_Request2( - $this->baseUrl . $name, HTTP_Request2::METHOD_GET, $this->config - ); - } - } - - /** - * Tests possibility to send GET parameters - * - * NB: Currently there are problems with Net_URL2::setQueryVariables(), thus - * array structure is simple: http://pear.php.net/bugs/bug.php?id=18267 - */ - public function testGetParameters() - { - $data = array( - 'bar' => array( - 'key' => 'value' - ), - 'foo' => 'some value', - 'numbered' => array('first', 'second') - ); - - $this->request->getUrl()->setQueryVariables($data); - $response = $this->request->send(); - $this->assertEquals(serialize($data), $response->getBody()); - } - - public function testPostParameters() - { - $data = array( - 'bar' => array( - 'key' => 'some other value' - ), - 'baz' => array( - 'key1' => array( - 'key2' => 'yet another value' - ) - ), - 'foo' => 'some value', - 'indexed' => array('first', 'second') - ); - $events = array( - 'sentHeaders', 'sentBodyPart', 'sentBody', 'receivedHeaders', 'receivedBodyPart', 'receivedBody' - ); - $observer = new EventSequenceObserver($events); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setHeader('Accept-Encoding', 'identity') - ->addPostParameter($data) - ->attach($observer); - - $response = $this->request->send(); - $this->assertEquals(serialize($data), $response->getBody()); - $this->assertEquals($events, $observer->sequence); - } - - public function testUploads() - { - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->addUpload('foo', dirname(dirname(dirname(__FILE__))) . '/_files/empty.gif', 'picture.gif', 'image/gif') - ->addUpload('bar', array( - array(dirname(dirname(dirname(__FILE__))) . '/_files/empty.gif', null, 'image/gif'), - array(dirname(dirname(dirname(__FILE__))) . '/_files/plaintext.txt', 'secret.txt', 'text/x-whatever') - )); - - $response = $this->request->send(); - $this->assertContains("foo picture.gif image/gif 43", $response->getBody()); - $this->assertContains("bar0 empty.gif image/gif 43", $response->getBody()); - $this->assertContains("bar1 secret.txt text/x-whatever 15", $response->getBody());
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2/Adapter/CurlTest.php
Deleted
@@ -1,180 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** Tests for HTTP_Request2 package that require a working webserver */ -require_once dirname(__FILE__) . '/CommonNetworkTest.php'; - -class UploadSizeObserver implements SplObserver -{ - public $size; - - public function update(SplSubject $subject) - { - /* @var $subject HTTP_Request2 */ - $event = $subject->getLastEvent(); - - if ('sentBody' == $event'name') { - $this->size = $event'data'; - } - } - -} - -/** - * Unit test for Curl Adapter of HTTP_Request2 - */ -class HTTP_Request2_Adapter_CurlTest extends HTTP_Request2_Adapter_CommonNetworkTest -{ - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Curl' - ); - - /** - * Checks whether redirect support in cURL is disabled by safe_mode or open_basedir - * @return bool - */ - protected function isRedirectSupportDisabled() - { - return ini_get('safe_mode') || ini_get('open_basedir'); - } - - public function testRedirectsDefault() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsDefault(); - } - } - - public function testRedirectsStrict() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } elseif (version_compare(phpversion(), '5.3.2', '<')) { - $this->markTestSkipped('CURLOPT_POSTREDIR required for strict redirects, available in PHP 5.3.2+'); - } else { - parent::testRedirectsStrict(); - } - } - - public function testRedirectsLimit() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsLimit(); - } - } - - public function testRedirectsRelative() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsRelative(); - } - } - - public function testRedirectsNonHTTP() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testRedirectsNonHTTP(); - } - } - - public function testCookieJarAndRedirect() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - } else { - parent::testCookieJarAndRedirect(); - } - } - - public function testBug17450() - { - if (!$this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Neither safe_mode nor open_basedir is enabled'); - } - - $this->request->setUrl($this->baseUrl . 'redirects.php') - ->setConfig(array('follow_redirects' => true)); - - try { - $this->request->send(); - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - - } catch (HTTP_Request2_LogicException $e) { - $this->assertEquals(HTTP_Request2_Exception::MISCONFIGURATION, $e->getCode()); - } - } - - public function testBug20440() - { - $this->request->setUrl($this->baseUrl . 'rawpostdata.php') - ->setMethod(HTTP_Request2::METHOD_PUT) - ->setHeader('Expect', '') - ->setBody('This is a test'); - - $noredirects = clone $this->request; - $noredirects->setConfig('follow_redirects', false) - ->attach($observer = new UploadSizeObserver()); - $noredirects->send(); - // Curl sends body with Transfer-encoding: chunked, so size can be larger - $this->assertGreaterThanOrEqual(14, $observer->size); - - $redirects = clone $this->request; - $redirects->setConfig('follow_redirects', true) - ->attach($observer = new UploadSizeObserver()); - $redirects->send(); - $this->assertGreaterThanOrEqual(14, $observer->size); - } - - /** - * An URL performing a redirect was used for storing cookies in a jar rather than target URL - * - * @link http://pear.php.net/bugs/bug.php?id=20561 - */ - public function testBug20561() - { - if ($this->isRedirectSupportDisabled()) { - $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); - - } else { - $this->request->setUrl($this->baseUrl . 'redirects.php?special=youtube') - ->setConfig(array( - 'follow_redirects' => true, - 'ssl_verify_peer' => false - )) - ->setCookieJar(true); - - $this->request->send(); - $this->assertGreaterThan(0, count($this->request->getCookieJar()->getAll())); - } - } -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2/Adapter/MockTest.php
Deleted
@@ -1,157 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** Sets up includes */ -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Mock adapter intended for testing - */ -require_once 'HTTP/Request2/Adapter/Mock.php'; - -/** - * Unit test for HTTP_Request2_Response class - */ -class HTTP_Request2_Adapter_MockTest extends PHPUnit_Framework_TestCase -{ - public function testDefaultResponse() - { - $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_GET, - array('adapter' => 'mock')); - $response = $req->send(); - $this->assertEquals(400, $response->getStatus()); - $this->assertEquals(0, count($response->getHeader())); - $this->assertEquals('', $response->getBody()); - } - - public function testResponseFromString() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a string" - ); - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - - $response = $req->send(); - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals(1, count($response->getHeader())); - $this->assertEquals('This is a string', $response->getBody()); - } - - public function testResponseFromFile() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse(fopen(dirname(dirname(dirname(__FILE__))) . - '/_files/response_headers', 'rb')); - - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - - $response = $req->send(); - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals(7, count($response->getHeader())); - $this->assertEquals('Nothing to see here, move along.', $response->getBody()); - } - - public function testResponsesQueue() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - "HTTP/1.1 301 Over there\r\n" . - "Location: http://www.example.com/newpage.html\r\n" . - "\r\n" . - "The document is over there" - ); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a string" - ); - - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - $this->assertEquals(301, $req->send()->getStatus()); - $this->assertEquals(200, $req->send()->getStatus()); - $this->assertEquals(400, $req->send()->getStatus()); - } - - /** - * Returning URL-specific responses - * @link http://pear.php.net/bugs/bug.php?id=19276 - */ - public function testRequest19276() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a response from example.org", - 'http://example.org/' - ); - $mock->addResponse( - "HTTP/1.1 200 OK\r\n" . - "Content-Type: text/plain; charset=iso-8859-1\r\n" . - "\r\n" . - "This is a response from example.com", - 'http://example.com/' - ); - - $req1 = new HTTP_Request2('http://localhost/'); - $req1->setAdapter($mock); - $this->assertEquals(400, $req1->send()->getStatus()); - - $req2 = new HTTP_Request2('http://example.com/'); - $req2->setAdapter($mock); - $this->assertContains('example.com', $req2->send()->getBody()); - - $req3 = new HTTP_Request2('http://example.org'); - $req3->setAdapter($mock); - $this->assertContains('example.org', $req3->send()->getBody()); - } - - public function testResponseException() - { - $mock = new HTTP_Request2_Adapter_Mock(); - $mock->addResponse( - new HTTP_Request2_Exception('Shit happens') - ); - $req = new HTTP_Request2('http://www.example.com/'); - $req->setAdapter($mock); - try { - $req->send(); - } catch (Exception $e) { - $this->assertEquals('Shit happens', $e->getMessage()); - return; - } - $this->fail('Expected HTTP_Request2_Exception was not thrown'); - } -} -?>
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2/Adapter/SkippedTests.php
Deleted
@@ -1,56 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** Sets up includes */ -require_once dirname(dirname(dirname(__FILE__))) . '/TestHelper.php'; - -/** - * Shows a skipped test if networked tests are not configured - */ -class HTTP_Request2_Adapter_Skip_SocketTest extends PHPUnit_Framework_TestCase -{ - public function testSocketAdapter() - { - $this->markTestSkipped('Socket Adapter tests need base URL configured.'); - } -} - -/** - * Shows a skipped test if proxy is not configured - */ -class HTTP_Request2_Adapter_Skip_SocketProxyTest extends PHPUnit_Framework_TestCase -{ - public function testSocketAdapterWithProxy() - { - $this->markTestSkipped('Socket Adapter proxy tests need base URL and proxy configured'); - } -} - -/** - * Shows a skipped test if networked tests are not configured or cURL extension is unavailable - */ -class HTTP_Request2_Adapter_Skip_CurlTest extends PHPUnit_Framework_TestCase -{ - public function testCurlAdapter() - { - $this->markTestSkipped('Curl Adapter tests need base URL configured and curl extension available'); - } -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2/Adapter/SocketProxyTest.php
Deleted
@@ -1,55 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** Tests for HTTP_Request2 package that require a working webserver */ -require_once dirname(__FILE__) . '/CommonNetworkTest.php'; - -/** - * Unit test for Socket Adapter of HTTP_Request2 working through proxy - */ -class HTTP_Request2_Adapter_SocketProxyTest extends HTTP_Request2_Adapter_CommonNetworkTest -{ - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket' - ); - - protected function setUp() - { - if (!defined('HTTP_REQUEST2_TESTS_PROXY_HOST') || !HTTP_REQUEST2_TESTS_PROXY_HOST) { - $this->markTestSkipped('Proxy is not configured'); - - } else { - $this->config += array( - 'proxy_host' => HTTP_REQUEST2_TESTS_PROXY_HOST, - 'proxy_port' => HTTP_REQUEST2_TESTS_PROXY_PORT, - 'proxy_user' => HTTP_REQUEST2_TESTS_PROXY_USER, - 'proxy_password' => HTTP_REQUEST2_TESTS_PROXY_PASSWORD, - 'proxy_auth_scheme' => HTTP_REQUEST2_TESTS_PROXY_AUTH_SCHEME, - 'proxy_type' => HTTP_REQUEST2_TESTS_PROXY_TYPE - ); - parent::setUp(); - } - } -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2/Adapter/SocketTest.php
Deleted
@@ -1,191 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** Tests for HTTP_Request2 package that require a working webserver */ -require_once dirname(__FILE__) . '/CommonNetworkTest.php'; - -/** Socket-based adapter for HTTP_Request2 */ -require_once 'HTTP/Request2/Adapter/Socket.php'; - -/** - * Unit test for Socket Adapter of HTTP_Request2 - */ -class HTTP_Request2_Adapter_SocketTest extends HTTP_Request2_Adapter_CommonNetworkTest -{ - /** - * Configuration for HTTP Request object - * @var array - */ - protected $config = array( - 'adapter' => 'HTTP_Request2_Adapter_Socket' - ); - - public function testBug17826() - { - $adapter = new HTTP_Request2_Adapter_Socket(); - - $request1 = new HTTP_Request2($this->baseUrl . 'redirects.php?redirects=2'); - $request1->setConfig(array('follow_redirects' => true, 'max_redirects' => 3)) - ->setAdapter($adapter) - ->send(); - - $request2 = new HTTP_Request2($this->baseUrl . 'redirects.php?redirects=2'); - $request2->setConfig(array('follow_redirects' => true, 'max_redirects' => 3)) - ->setAdapter($adapter) - ->send(); - } - - - /** - * Infinite loop with stream wrapper passed as upload - * - * Dunno how the original reporter managed to pass a file pointer - * that doesn't support fstat() to MultipartBody, maybe he didn't use - * addUpload(). So we don't use it, either. - * - * @link http://pear.php.net/bugs/bug.php?id=19934 - */ - public function testBug19934() - { - if (!in_array('http', stream_get_wrappers())) { - $this->markTestSkipped("This test requires an HTTP fopen wrapper enabled"); - } - - $fp = fopen($this->baseUrl . '/bug19934.php', 'rb'); - $body = new HTTP_Request2_MultipartBody( - array(), - array( - 'upload' => array( - 'fp' => $fp, - 'filename' => 'foo.txt', - 'type' => 'text/plain', - 'size' => 20000 - ) - ) - ); - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl($this->baseUrl . 'uploads.php') - ->setBody($body); - - set_error_handler(array($this, 'rewindWarningsHandler')); - $response = $this->request->send(); - restore_error_handler(); - - $this->assertContains("upload foo.txt text/plain 20000", $response->getBody()); - } - - public function rewindWarningsHandler($errno, $errstr) - { - if (($errno & E_WARNING) && false !== strpos($errstr, 'rewind')) { - return true; - } - return false; - } - - /** - * Do not send request body twice to URLs protected by digest auth - * - * @link http://pear.php.net/bugs/bug.php?id=19233 - */ - public function test100ContinueHandling() - { - if (!defined('HTTP_REQUEST2_TESTS_DIGEST_URL') || !HTTP_REQUEST2_TESTS_DIGEST_URL) { - $this->markTestSkipped('This test requires an URL protected by server digest auth'); - } - - $fp = fopen(dirname(dirname(dirname(__FILE__))) . '/_files/bug_15305', 'rb'); - $body = $this->getMock( - 'HTTP_Request2_MultipartBody', array('read'), array( - array(), - array( - 'upload' => array( - 'fp' => $fp, - 'filename' => 'bug_15305', - 'type' => 'application/octet-stream', - 'size' => 16338 - ) - ) - ) - ); - $body->expects($this->never())->method('read'); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl(HTTP_REQUEST2_TESTS_DIGEST_URL) - ->setBody($body); - - $this->assertEquals(401, $this->request->send()->getStatus()); - } - - public function test100ContinueTimeoutBug() - { - $fp = fopen(dirname(dirname(dirname(__FILE__))) . '/_files/bug_15305', 'rb'); - $body = new HTTP_Request2_MultipartBody( - array(), - array( - 'upload' => array( - 'fp' => $fp, - 'filename' => 'bug_15305', - 'type' => 'application/octet-stream', - 'size' => 16338 - ) - ) - ); - - $this->request->setMethod(HTTP_Request2::METHOD_POST) - ->setUrl($this->baseUrl . 'uploads.php?slowpoke') - ->setBody($body); - - $response = $this->request->send(); - $this->assertContains('upload bug_15305 application/octet-stream 16338', $response->getBody()); - } - - /** - * Socket adapter should not throw an exception (invalid chunk length '') - * if a buggy server doesn't send last zero-length chunk when using chunked encoding - * - * @link http://pear.php.net/bugs/bug.php?id=20228 - */ - public function testBug20228() - { - $events = array('receivedBodyPart', 'warning', 'receivedBody'); - $this->request->setHeader('Accept-Encoding', 'identity') - ->attach($observer = new EventSequenceObserver($events)); - $response = $this->request->send(); - $this->assertEquals('This is a test', $response->getBody()); - $this->assertEquals($events, $observer->sequence); - } - - public function testHowsMySSL() - { - $this->request->setUrl('https://www.howsmyssl.com/a/check') - ->setConfig('ssl_verify_peer', false); - - if (null === ($responseData = json_decode($this->request->send()->getBody(), true))) { - $this->fail('Cannot decode JSON from howsmyssl.com response'); - } - - $this->assertEmpty($responseData'insecure_cipher_suites'); - - if (version_compare(phpversion(), '5.6', '>=')) { - $this->assertEquals('Probably Okay', $responseData'rating'); - } - } -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2/AllTests.php
Deleted
@@ -1,60 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -if (!defined('PHPUnit_MAIN_METHOD')) { - if (strpos($_SERVER'argv'0, 'phpunit') === false) { - define('PHPUnit_MAIN_METHOD', 'Request2_AllTests::main'); - } else { - define('PHPUnit_MAIN_METHOD', false); - } -} - -require_once dirname(__FILE__) . '/CookieJarTest.php'; -require_once dirname(__FILE__) . '/MultipartBodyTest.php'; -require_once dirname(__FILE__) . '/ResponseTest.php'; -require_once dirname(__FILE__) . '/Adapter/AllTests.php'; - -class Request2_AllTests -{ - public static function main() - { - if (!class_exists('PHPUnit_TextUI_TestRunner', true)) { - require_once 'PHPUnit/TextUI/TestRunner.php'; - } - PHPUnit_TextUI_TestRunner::run(self::suite()); - } - - public static function suite() - { - $suite = new PHPUnit_Framework_TestSuite('HTTP_Request2 package - Request2'); - - $suite->addTestSuite('HTTP_Request2_CookieJarTest'); - $suite->addTestSuite('HTTP_Request2_MultipartBodyTest'); - $suite->addTestSuite('HTTP_Request2_ResponseTest'); - $suite->addTest(Request2_Adapter_AllTests::suite()); - - return $suite; - } -} - -if (PHPUnit_MAIN_METHOD == 'Request2_AllTests::main') { - Request2_AllTests::main(); -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2/CookieJarTest.php
Deleted
@@ -1,403 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** Sets up includes */ -require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; -/** Stores cookies and passes them between HTTP requests */ -require_once 'HTTP/Request2/CookieJar.php'; -/** Mock adapter intended for testing */ -require_once 'HTTP/Request2/Adapter/Mock.php'; - -/** - * Unit test for HTTP_Request2_CookieJar class - */ -class HTTP_Request2_CookieJarTest extends PHPUnit_Framework_TestCase -{ - /** - * Cookie jar instance being tested - * @var HTTP_Request2_CookieJar - */ - protected $jar; - - protected function setUp() - { - $this->jar = new HTTP_Request2_CookieJar(); - } - - /** - * Test that we can't store junk "cookies" in jar - * - * @dataProvider invalidCookieProvider - * @expectedException HTTP_Request2_LogicException - */ - public function testStoreInvalid($cookie) - { - $this->jar->store($cookie); - } - - /** - * Per feature requests, allow to ignore invalid cookies rather than throw exceptions - * - * @link http://pear.php.net/bugs/bug.php?id=19937 - * @link http://pear.php.net/bugs/bug.php?id=20401 - * @dataProvider invalidCookieProvider - */ - public function testCanIgnoreInvalidCookies($cookie) - { - $this->jar->ignoreInvalidCookies(true); - $this->assertFalse($this->jar->store($cookie)); - } - - /** - * Ignore setting a cookie from "parallel" subdomain when relevant option is on - * - * @link http://pear.php.net/bugs/bug.php?id=20401 - */ - public function testRequest20401() - { - $this->jar->ignoreInvalidCookies(true); - $response = HTTP_Request2_Adapter_Mock::createResponseFromFile( - fopen(dirname(dirname(__FILE__)) . '/_files/response_cookies', 'rb') - ); - $setter = new Net_URL2('http://pecl.php.net/'); - - $this->assertFalse($this->jar->addCookiesFromResponse($response, $setter)); - $this->assertCount(3, $this->jar->getAll()); - } - - - /** - * - * @dataProvider noPSLDomainsProvider - */ - public function testDomainMatchNoPSL($requestHost, $cookieDomain, $expected) - { - $this->jar->usePublicSuffixList(false); - $this->assertEquals($expected, $this->jar->domainMatch($requestHost, $cookieDomain)); - } - - /** - * - * @dataProvider PSLDomainsProvider - */ - public function testDomainMatchPSL($requestHost, $cookieDomain, $expected) - { - $this->jar->usePublicSuffixList(true); - $this->assertEquals($expected, $this->jar->domainMatch($requestHost, $cookieDomain)); - } - - public function testConvertExpiresToISO8601() - { - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - $dt->modify('+1 day'); - - $this->jar->store(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => $dt->format(DateTime::COOKIE), - 'secure' => false - )); - $cookies = $this->jar->getAll(); - $this->assertEquals($cookies0'expires', $dt->format(DateTime::ISO8601)); - } - - public function testProblem2038() - { - $this->jar->store(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => 'Sun, 01 Jan 2040 03:04:05 GMT', - 'secure' => false - )); - $cookies = $this->jar->getAll(); - $this->assertEquals(array(array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'expires' => '2040-01-01T03:04:05+0000', - 'secure' => false - )), $cookies); - } - - public function testStoreExpired() - { - $base = array( - 'name' => 'foo', - 'value' => 'bar', - 'domain' => '.example.com', - 'path' => '/', - 'secure' => false - ); - - $dt = new DateTime(); - $dt->setTimezone(new DateTimeZone('UTC')); - $dt->modify('-1 day'); - $yesterday = $dt->format(DateTime::COOKIE); - - $dt->modify('+2 days'); - $tomorrow = $dt->format(DateTime::COOKIE); - - $this->jar->store($base + array('expires' => $yesterday)); - $this->assertEquals(0, count($this->jar->getAll())); - - $this->jar->store($base + array('expires' => $tomorrow)); - $this->assertEquals(1, count($this->jar->getAll())); - $this->jar->store($base + array('expires' => $yesterday)); - $this->assertEquals(0, count($this->jar->getAll())); - } - - /** - * - * @dataProvider cookieAndSetterProvider - */ - public function testGetDomainAndPathFromSetter($cookie, $setter, $expected) - { - $this->jar->store($cookie, $setter); - $expected = array_merge($cookie, $expected); - $cookies = $this->jar->getAll(); - $this->assertEquals($expected, $cookies0); - } - - /** - * - * @dataProvider cookieMatchProvider - */ - public function testGetMatchingCookies($url, $expectedCount) - { - $cookies = array( - array('domain' => '.example.com', 'path' => '/', 'secure' => false), - array('domain' => '.example.com', 'path' => '/', 'secure' => true), - array('domain' => '.example.com', 'path' => '/path', 'secure' => false), - array('domain' => '.example.com', 'path' => '/other', 'secure' => false), - array('domain' => 'example.com', 'path' => '/', 'secure' => false), - array('domain' => 'www.example.com', 'path' => '/', 'secure' => false), - array('domain' => 'specific.example.com', 'path' => '/path', 'secure' => false), - array('domain' => 'nowww.example.com', 'path' => '/', 'secure' => false), - );
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2/MultipartBodyTest.php
Deleted
@@ -1,102 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** Sets up includes */ -require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Unit test for HTTP_Request2_MultipartBody class - */ -class HTTP_Request2_MultipartBodyTest extends PHPUnit_Framework_TestCase -{ - public function testUploadSimple() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $body = $req->addPostParameter('foo', 'I am a parameter') - ->addUpload('upload', dirname(dirname(__FILE__)) . '/_files/plaintext.txt') - ->getBody(); - - $this->assertTrue($body instanceof HTTP_Request2_MultipartBody); - $asString = $body->__toString(); - $boundary = $body->getBoundary(); - $this->assertEquals($body->getLength(), strlen($asString)); - $this->assertContains('This is a test.', $asString); - $this->assertContains('I am a parameter', $asString); - $this->assertRegexp("!--{$boundary}--\r\n$!", $asString); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testRequest16863() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $fp = fopen(dirname(dirname(__FILE__)) . '/_files/plaintext.txt', 'rb'); - $body = $req->addUpload('upload', $fp) - ->getBody(); - - $asString = $body->__toString(); - $this->assertContains('name="upload"; filename="anonymous.blob"', $asString); - $this->assertContains('This is a test.', $asString); - - $req->addUpload('bad_upload', fopen('php://input', 'rb')); - } - - public function testStreaming() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $body = $req->addPostParameter('foo', 'I am a parameter') - ->addUpload('upload', dirname(dirname(__FILE__)) . '/_files/plaintext.txt') - ->getBody(); - $asString = ''; - while ($part = $body->read(10)) { - $asString .= $part; - } - $this->assertEquals($body->getLength(), strlen($asString)); - $this->assertContains('This is a test.', $asString); - $this->assertContains('I am a parameter', $asString); - } - - public function testUploadArray() - { - $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); - $body = $req->addUpload('upload', array( - array(dirname(dirname(__FILE__)) . '/_files/plaintext.txt', 'bio.txt', 'text/plain'), - array(fopen(dirname(dirname(__FILE__)) . '/_files/empty.gif', 'rb'), 'photo.gif', 'image/gif') - )) - ->getBody(); - $asString = $body->__toString(); - $this->assertContains(file_get_contents(dirname(dirname(__FILE__)) . '/_files/empty.gif'), $asString); - $this->assertContains('name="upload0"; filename="bio.txt"', $asString); - $this->assertContains('name="upload1"; filename="photo.gif"', $asString); - - $body2 = $req->setConfig(array('use_brackets' => false))->getBody(); - $asString = $body2->__toString(); - $this->assertContains('name="upload"; filename="bio.txt"', $asString); - $this->assertContains('name="upload"; filename="photo.gif"', $asString); - } -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2/ResponseTest.php
Deleted
@@ -1,128 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** Sets up includes */ -require_once dirname(dirname(__FILE__)) . '/TestHelper.php'; - -/** - * Class representing a HTTP response - */ -require_once 'HTTP/Request2/Response.php'; - -/** - * Unit test for HTTP_Request2_Response class - */ -class HTTP_Request2_ResponseTest extends PHPUnit_Framework_TestCase -{ - /** - * - * @expectedException HTTP_Request2_MessageException - */ - public function testParseStatusLine() - { - $response = new HTTP_Request2_Response('HTTP/1.1 200 OK'); - $this->assertEquals('1.1', $response->getVersion()); - $this->assertEquals(200, $response->getStatus()); - $this->assertEquals('OK', $response->getReasonPhrase()); - - $response2 = new HTTP_Request2_Response('HTTP/1.2 222 Nishtyak!'); - $this->assertEquals('1.2', $response2->getVersion()); - $this->assertEquals(222, $response2->getStatus()); - $this->assertEquals('Nishtyak!', $response2->getReasonPhrase()); - - $response3 = new HTTP_Request2_Response('Invalid status line'); - } - - public function testParseHeaders() - { - $response = $this->readResponseFromFile('response_headers'); - $this->assertEquals(7, count($response->getHeader())); - $this->assertEquals('PHP/6.2.2', $response->getHeader('X-POWERED-BY')); - $this->assertEquals('text/html; charset=windows-1251', $response->getHeader('cOnTeNt-TyPe')); - $this->assertEquals('accept-charset, user-agent', $response->getHeader('vary')); - } - - public function testParseCookies() - { - $response = $this->readResponseFromFile('response_cookies'); - $cookies = $response->getCookies(); - $this->assertEquals(4, count($cookies)); - $expected = array( - array('name' => 'foo', 'value' => 'bar', 'expires' => null, - 'domain' => null, 'path' => null, 'secure' => false), - array('name' => 'PHPSESSID', 'value' => '1234567890abcdef1234567890abcdef', - 'expires' => null, 'domain' => null, 'path' => '/', 'secure' => true), - array('name' => 'A', 'value' => 'B=C', 'expires' => null, - 'domain' => null, 'path' => null, 'secure' => false), - array('name' => 'baz', 'value' => '%20a%20value', 'expires' => 'Sun, 03 Jan 2010 03:04:05 GMT', - 'domain' => 'pear.php.net', 'path' => null, 'secure' => false), - ); - foreach ($cookies as $k => $cookie) { - $this->assertEquals($expected$k, $cookie); - } - } - - /** - * - * @expectedException HTTP_Request2_MessageException - */ - public function testGzipEncoding() - { - $response = $this->readResponseFromFile('response_gzip'); - $this->assertEquals('0e964e9273c606c46afbd311b5ad4d77', md5($response->getBody())); - - $response = $this->readResponseFromFile('response_gzip_broken'); - $body = $response->getBody(); - } - - public function testDeflateEncoding() - { - $response = $this->readResponseFromFile('response_deflate'); - $this->assertEquals('0e964e9273c606c46afbd311b5ad4d77', md5($response->getBody())); - } - - public function testBug15305() - { - $response = $this->readResponseFromFile('bug_15305'); - $this->assertEquals('c8c5088fc8a7652afef380f086c010a6', md5($response->getBody())); - } - - public function testBug18169() - { - $response = $this->readResponseFromFile('bug_18169'); - $this->assertEquals('', $response->getBody()); - } - - protected function readResponseFromFile($filename) - { - $fp = fopen(dirname(dirname(__FILE__)) . '/_files/' . $filename, 'rb'); - $response = new HTTP_Request2_Response(fgets($fp)); - do { - $headerLine = fgets($fp); - $response->parseHeaderLine($headerLine); - } while ('' != trim($headerLine)); - - while (!feof($fp)) { - $response->appendBody(fread($fp, 1024)); - } - return $response; - } -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/Request2Test.php
Deleted
@@ -1,392 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** Sets up includes */ -require_once dirname(__FILE__) . '/TestHelper.php'; - -/** - * Class representing a HTTP request - */ -require_once 'HTTP/Request2.php'; - -/** - * Unit test for HTTP_Request2 class - */ -class HTTP_Request2Test extends PHPUnit_Framework_TestCase -{ - public function testConstructorSetsDefaults() - { - $url = new Net_URL2('http://www.example.com/foo'); - $req = new HTTP_Request2($url, HTTP_Request2::METHOD_POST, array('connect_timeout' => 666)); - - $this->assertSame($url, $req->getUrl()); - $this->assertEquals(HTTP_Request2::METHOD_POST, $req->getMethod()); - $this->assertEquals(666, $req->getConfig('connect_timeout')); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testSetUrl() - { - $urlString = 'http://www.example.com/foo/bar.php'; - $url = new Net_URL2($urlString); - - $req1 = new HTTP_Request2(); - $req1->setUrl($url); - $this->assertSame($url, $req1->getUrl()); - - $req2 = new HTTP_Request2(); - $req2->setUrl($urlString); - $this->assertInstanceOf('Net_URL2', $req2->getUrl()); - $this->assertEquals($urlString, $req2->getUrl()->getUrl()); - - $req3 = new HTTP_Request2(); - $req3->setUrl(array('This will cause an error')); - } - - public function testConvertUserinfoToAuth() - { - $req = new HTTP_Request2(); - $req->setUrl('http://foo:b%40r@www.example.com/'); - - $this->assertEquals('', (string)$req->getUrl()->getUserinfo()); - $this->assertEquals( - array('user' => 'foo', 'password' => 'b@r', 'scheme' => HTTP_Request2::AUTH_BASIC), - $req->getAuth() - ); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testSetMethod() - { - $req = new HTTP_Request2(); - $req->setMethod(HTTP_Request2::METHOD_PUT); - $this->assertEquals(HTTP_Request2::METHOD_PUT, $req->getMethod()); - - $req->setMethod('Invalid method'); - } - - public function testSetAndGetConfig() - { - $req = new HTTP_Request2(); - $this->assertArrayHasKey('connect_timeout', $req->getConfig()); - - $req->setConfig(array('connect_timeout' => 123)); - $this->assertEquals(123, $req->getConfig('connect_timeout')); - try { - $req->setConfig(array('foo' => 'unknown parameter')); - $this->fail('Expected HTTP_Request2_LogicException was not thrown'); - } catch (HTTP_Request2_LogicException $e) {} - - try { - $req->getConfig('bar'); - $this->fail('Expected HTTP_Request2_LogicException was not thrown'); - } catch (HTTP_Request2_LogicException $e) {} - } - - public function testSetProxyAsUrl() - { - $req = new HTTP_Request2(); - $req->setConfig('proxy', 'socks5://foo:bar%25baz@localhost:1080/'); - - $this->assertEquals('socks5', $req->getConfig('proxy_type')); - $this->assertEquals('localhost', $req->getConfig('proxy_host')); - $this->assertEquals(1080, $req->getConfig('proxy_port')); - $this->assertEquals('foo', $req->getConfig('proxy_user')); - $this->assertEquals('bar%baz', $req->getConfig('proxy_password')); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testHeaders() - { - $req = new HTTP_Request2(); - $autoHeaders = $req->getHeaders(); - - $req->setHeader('Foo', 'Bar'); - $req->setHeader('Foo-Bar: value'); - $req->setHeader(array('Another-Header' => 'another value', 'Yet-Another: other_value')); - $this->assertEquals( - array('foo-bar' => 'value', 'another-header' => 'another value', - 'yet-another' => 'other_value', 'foo' => 'Bar') + $autoHeaders, - $req->getHeaders() - ); - - $req->setHeader('FOO-BAR'); - $req->setHeader(array('aNOTHER-hEADER')); - $this->assertEquals( - array('yet-another' => 'other_value', 'foo' => 'Bar') + $autoHeaders, - $req->getHeaders() - ); - - $req->setHeader('Invalid header', 'value'); - } - - public function testBug15937() - { - $req = new HTTP_Request2(); - $autoHeaders = $req->getHeaders(); - - $req->setHeader('Expect: '); - $req->setHeader('Foo', ''); - $this->assertEquals( - array('expect' => '', 'foo' => '') + $autoHeaders, - $req->getHeaders() - ); - } - - public function testRequest17507() - { - $req = new HTTP_Request2(); - - $req->setHeader('accept-charset', 'iso-8859-1'); - $req->setHeader('accept-charset', array('windows-1251', 'utf-8'), false); - - $req->setHeader(array('accept' => 'text/html')); - $req->setHeader(array('accept' => 'image/gif'), null, false); - - $headers = $req->getHeaders(); - - $this->assertEquals('iso-8859-1, windows-1251, utf-8', $headers'accept-charset'); - $this->assertEquals('text/html, image/gif', $headers'accept'); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testCookies() - { - $req = new HTTP_Request2(); - $req->addCookie('name', 'value'); - $req->addCookie('foo', 'bar'); - $headers = $req->getHeaders(); - $this->assertEquals('name=value; foo=bar', $headers'cookie'); - - $req->addCookie('invalid cookie', 'value'); - } - - /** - * - * @expectedException HTTP_Request2_LogicException - */ - public function testPlainBody() - { - $req = new HTTP_Request2();
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/TestHelper.php
Deleted
@@ -1,50 +0,0 @@ -<?php -/** - * Unit tests for HTTP_Request2 package - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -// If running from SVN checkout, update include_path -if ('@' . 'package_version@' == '2.3.0') { - $classPath = realpath(dirname(dirname(__FILE__))); - $includePath = array($classPath); - - foreach (explode(PATH_SEPARATOR, get_include_path()) as $component) { - if (false !== ($real = realpath($component)) && $real !== $classPath) { - $includePath = $real; - } - } - - set_include_path(implode(PATH_SEPARATOR, $includePath)); -} - -if (strpos($_SERVER'argv'0, 'phpunit') === false) { - /** Include PHPUnit dependencies based on version */ - require_once 'PHPUnit/Runner/Version.php'; - if (version_compare(PHPUnit_Runner_Version::id(), '3.5.0', '>=')) { - require_once 'PHPUnit/Autoload.php'; - } else { - require_once 'PHPUnit/Framework.php'; - } -} - -if (!defined('HTTP_REQUEST2_TESTS_BASE_URL') - && is_readable(dirname(__FILE__) . '/NetworkConfig.php') -) { - require_once dirname(__FILE__) . '/NetworkConfig.php'; -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/basicauth.php
Deleted
@@ -1,33 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -$user = isset($_SERVER'PHP_AUTH_USER') ? $_SERVER'PHP_AUTH_USER' : null; -$pass = isset($_SERVER'PHP_AUTH_PW') ? $_SERVER'PHP_AUTH_PW' : null; -$wantedUser = isset($_GET'user') ? $_GET'user' : null; -$wantedPass = isset($_GET'pass') ? $_GET'pass' : null; - -if (!$user || !$pass || $user != $wantedUser || $pass != $wantedPass) { - header('WWW-Authenticate: Basic realm="HTTP_Request2 tests"', true, 401); - echo "Login required"; -} else { - echo "Username={$user};Password={$pass}"; -} - -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/bug19934.php
Deleted
@@ -1,27 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -for ($i = 0; $i < 20; $i++) { - for ($j = 0; $j < 10; $j++) { - echo str_repeat((string)$j, 98) . "\r\n"; - } - flush(); - usleep(50000); -} \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/bug20228.php
Deleted
@@ -1,24 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -header('Transfer-Encoding: chunked'); - -echo "e\r\n"; -echo "This is a test\r\n";
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/cookies.php
Deleted
@@ -1,24 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -ksort($_COOKIE); -echo serialize($_COOKIE); - -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/digestauth.php
Deleted
@@ -1,83 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -/** - * Mostly borrowed from PHP manual and Socket Adapter implementation - * - * @link http://php.net/manual/en/features.http-auth.php - */ - -/** - * Parses the Digest auth header - * - * @param string $txt - */ -function http_digest_parse($txt) -{ - $token = '^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\\?={}\s+'; - $quoted = '"(?:\\\\.|^\\\\")*"'; - - // protect against missing data - $needed_parts = array_flip(array('nonce', 'nc', 'cnonce', 'qop', 'username', 'uri', 'response')); - $data = array(); - - preg_match_all("!({$token})\\s*=\\s*({$token}|{$quoted})!", $txt, $matches); - for ($i = 0; $i < count($matches0); $i++) { - // ignore unneeded parameters - if (isset($needed_parts$matches1$i)) { - unset($needed_parts$matches1$i); - if ('"' == substr($matches2$i, 0, 1)) { - $data$matches1$i = substr($matches2$i, 1, -1); - } else { - $data$matches1$i = $matches2$i; - } - } - } - - return !empty($needed_parts) ? false : $data; -} - -$realm = 'HTTP_Request2 tests'; -$wantedUser = isset($_GET'user') ? $_GET'user' : null; -$wantedPass = isset($_GET'pass') ? $_GET'pass' : null; -$validAuth = false; - -if (!empty($_SERVER'PHP_AUTH_DIGEST') - && ($data = http_digest_parse($_SERVER'PHP_AUTH_DIGEST')) - && $wantedUser == $data'username' -) { - // generate the valid response - $a1 = md5($data'username' . ':' . $realm . ':' . $wantedPass); - $a2 = md5($_SERVER'REQUEST_METHOD' . ':' . $data'uri'); - $response = md5($a1. ':' . $data'nonce' . ':' . $data'nc' . ':' - . $data'cnonce' . ':' . $data'qop' . ':' . $a2); - - // check valid response against existing one - $validAuth = ($data'response' == $response); -} - -if (!$validAuth || empty($_SERVER'PHP_AUTH_DIGEST')) { - header('WWW-Authenticate: Digest realm="' . $realm . - '",qop="auth",nonce="' . uniqid() . '"', true, 401); - echo "Login required"; -} else { - echo "Username={$data'username'}"; -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/download.php
Deleted
@@ -1,45 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -$payload = str_repeat('0123456789abcdef', 128); - -if (array_key_exists('gzip', $_GET)) { - // we inject a long "filename" into the header to check whether the downloader - // can handle an incomplete header in "slowpoke" mode - $payload = pack('c4Vc2', 0x1f, 0x8b, 8, 8, time(), 2, 255) - . str_repeat('a_really_really_long_file_name', 10) . '.txt' . chr(0) - . gzdeflate($payload) - . pack('V2', crc32($payload), 2048); - header('Content-Encoding: gzip'); -} - -if (!array_key_exists('slowpoke', $_GET)) { - echo $payload; - -} else { - $pos = 0; - $length = strlen($payload); - while ($pos < $length) { - echo substr($payload, $pos, 65); - $pos += 65; - flush(); - usleep(50000); - } -} \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/getparameters.php
Deleted
@@ -1,24 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -ksort($_GET); -echo serialize($_GET); - -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/incompletebody.php
Deleted
@@ -1,32 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -header('Connection: close'); - -if (array_key_exists('chunked', $_GET)) { - header('Transfer-Encoding: chunked'); - echo "2A\r\n"; - -} else { - header('Content-Length: 42'); -} - -echo "This is a test"; -flush(); \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/postparameters.php
Deleted
@@ -1,24 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -ksort($_POST); -echo serialize($_POST); - -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/rawpostdata.php
Deleted
@@ -1,22 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -readfile('php://input'); -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/redirects.php
Deleted
@@ -1,50 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -$redirects = isset($_GET'redirects')? $_GET'redirects': 1; -$https = !empty($_SERVER'HTTPS') && ('off' != strtolower($_SERVER'HTTPS')); -$special = isset($_GET'special')? $_GET'special': null; - -if ('ftp' == $special) { - header('Location: ftp://localhost/pub/exploit.exe', true, 301); - -} elseif ('youtube' == $special) { - header('Location: https://youtube.com/', true, 301); - -} elseif ('relative' == $special) { - header('Location: ./getparameters.php?msg=did%20relative%20redirect', true, 302); - -} elseif ('cookie' == $special) { - setcookie('cookie_on_redirect', 'success'); - header('Location: ./cookies.php', true, 302); - -} elseif ($redirects > 0) { - $url = ($https? 'https': 'http') . '://' . $_SERVER'SERVER_NAME' - . (($https && 443 == $_SERVER'SERVER_PORT' || !$https && 80 == $_SERVER'SERVER_PORT') - ? '' : ':' . $_SERVER'SERVER_PORT') - . $_SERVER'PHP_SELF' . '?redirects=' . (--$redirects); - header('Location: ' . $url, true, 302); - -} else { - echo "Method=" . $_SERVER'REQUEST_METHOD' . ';'; - var_dump($_POST); - var_dump($_GET); -} -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/setcookie.php
Deleted
@@ -1,27 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -$name = empty($_GET'name')? 'foo': $_GET'name'; -$value = empty($_GET'value')? 'bar': $_GET'value'; - -setcookie($name, $value); - -echo "Cookie set!"; -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/timeout.php
Deleted
@@ -1,23 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -sleep(5); - -?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/HTTP_Request2-2.3.0/tests/_network/uploads.php
Deleted
@@ -1,36 +0,0 @@ -<?php -/** - * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. - * - * PHP version 5 - * - * LICENSE - * - * 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 - * - * @category HTTP - * @package HTTP_Request2 - * @author Alexey Borzov <avb@php.net> - * @copyright 2008-2016 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 - */ - -if (isset($_GET'slowpoke')) { - sleep(3); -} - -if (!empty($_FILES)) { - foreach ($_FILES as $name => $file) { - if (is_array($file'name')) { - foreach($file'name' as $k => $v) { - echo "{$name}{$k} {$v} {$file'type'$k} {$file'size'$k}\n"; - } - } else { - echo "{$name} {$file'name'} {$file'type'} {$file'size'}\n"; - } - } -} -?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2.php
Added
@@ -0,0 +1,1057 @@ +<?php +/** + * Class representing a HTTP request message + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** + * A class representing an URL as per RFC 3986. + */ +require_once 'Net/URL2.php'; + +/** + * Exception class for HTTP_Request2 package + */ +require_once 'HTTP/Request2/Exception.php'; + +/** + * Class representing a HTTP request message + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + * @link http://tools.ietf.org/html/rfc2616#section-5 + */ +class HTTP_Request2 implements SplSubject +{ + /** + * #@+ + * Constants for HTTP request methods + * + * @link http://tools.ietf.org/html/rfc2616#section-5.1.1 + */ + const METHOD_OPTIONS = 'OPTIONS'; + const METHOD_GET = 'GET'; + const METHOD_HEAD = 'HEAD'; + const METHOD_POST = 'POST'; + const METHOD_PUT = 'PUT'; + const METHOD_DELETE = 'DELETE'; + const METHOD_TRACE = 'TRACE'; + const METHOD_CONNECT = 'CONNECT'; + /** + * #@- + */ + + /** + * #@+ + * Constants for HTTP authentication schemes + * + * @link http://tools.ietf.org/html/rfc2617 + */ + const AUTH_BASIC = 'basic'; + const AUTH_DIGEST = 'digest'; + /** + * #@- + */ + + /** + * Regular expression used to check for invalid symbols in RFC 2616 tokens + * + * @link http://pear.php.net/bugs/bug.php?id=15630 + */ + const REGEXP_INVALID_TOKEN = '!\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\\?={}\s!'; + + /** + * Regular expression used to check for invalid symbols in cookie strings + * + * @link http://pear.php.net/bugs/bug.php?id=15630 + * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html + */ + const REGEXP_INVALID_COOKIE = '/\s,;/'; + + /** + * Fileinfo magic database resource + * + * @var resource|null + * @see detectMimeType() + */ + private static $_fileinfoDb = null; + + /** + * Observers attached to the request (instances of SplObserver) + * + * @var array + */ + protected $observers = ; + + /** + * Request URL + * + * @var Net_URL2 + */ + protected $url; + + /** + * Request method + * + * @var string + */ + protected $method = self::METHOD_GET; + + /** + * Authentication data + * + * @var null|array{user: string, password: string, scheme: string} + * @see getAuth() + */ + protected $auth; + + /** + * Request headers + * + * @var array + */ + protected $headers = ; + + /** + * Configuration parameters + * + * @var array + * @see setConfig() + */ + protected $config = + 'adapter' => 'HTTP_Request2_Adapter_Socket', + 'connect_timeout' => 10, + 'timeout' => 0, + 'use_brackets' => true, + 'protocol_version' => '1.1', + 'buffer_size' => 16384, + 'store_body' => true, + 'local_ip' => null, + + 'proxy_host' => '', + 'proxy_port' => '', + 'proxy_user' => '', + 'proxy_password' => '', + 'proxy_auth_scheme' => self::AUTH_BASIC, + 'proxy_type' => 'http', + + 'ssl_verify_peer' => true, + 'ssl_verify_host' => true, + 'ssl_cafile' => null, + 'ssl_capath' => null, + 'ssl_local_cert' => null, + 'ssl_passphrase' => null, + + 'digest_compat_ie' => false, + + 'follow_redirects' => false, + 'max_redirects' => 5, + 'strict_redirects' => false + ; + + /** + * Last event in request / response handling, intended for observers + * + * @var array + * @see getLastEvent() + */ + protected $lastEvent = + 'name' => 'start', + 'data' => null + ; + + /** + * Request body + * + * @var string|resource|HTTP_Request2_MultipartBody + * @see setBody() + */ + protected $body = ''; + + /** + * Array of POST parameters + * + * @var array + */ + protected $postParams = ; + + /** + * Array of file uploads (for multipart/form-data POST requests) + * + * @var array
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/Adapter.php
Added
@@ -0,0 +1,143 @@ +<?php +/** + * Base class for HTTP_Request2 adapters + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 response + */ +require_once 'HTTP/Request2/Response.php'; + +/** + * Base class for HTTP_Request2 adapters + * + * HTTP_Request2 class itself only defines methods for aggregating the request + * data, all actual work of sending the request to the remote server and + * receiving its response is performed by adapters. + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + */ +abstract class HTTP_Request2_Adapter +{ + /** + * A list of methods that MUST NOT have a request body, per RFC 2616 + * + * @var array + */ + protected static $bodyDisallowed = 'TRACE'; + + /** + * Methods having defined semantics for request body + * + * Content-Length header (indicating that the body follows, section 4.3 of + * RFC 2616) will be sent for these methods even if no body was added + * + * @var array + * @link http://pear.php.net/bugs/bug.php?id=12900 + * @link http://pear.php.net/bugs/bug.php?id=14740 + */ + protected static $bodyRequired = 'POST', 'PUT'; + + /** + * Request being sent + * + * @var HTTP_Request2 + */ + protected $request; + + /** + * Request body + * + * @var string|resource|HTTP_Request2_MultipartBody + * @see HTTP_Request2::getBody() + */ + protected $requestBody; + + /** + * Length of the request body + * + * @var integer + */ + protected $contentLength; + + /** + * Sends request to the remote server and returns its response + * + * @param HTTP_Request2 $request HTTP request message + * + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + */ + abstract public function sendRequest(HTTP_Request2 $request); + + /** + * Calculates length of the request body, adds proper headers + * + * @param array $headers associative array of request headers, this method + * will add proper 'Content-Length' and 'Content-Type' + * headers to this array (or remove them if not needed) + * + * @return void + */ + protected function calculateRequestLength(&$headers) + { + $this->requestBody = $this->request->getBody(); + + if (is_string($this->requestBody)) { + $this->contentLength = strlen($this->requestBody); + } elseif (is_resource($this->requestBody)) { + $stat = fstat($this->requestBody); + $this->contentLength = $stat'size'; + rewind($this->requestBody); + } else { + $this->contentLength = $this->requestBody->getLength(); + $headers'content-type' = 'multipart/form-data; boundary=' . + $this->requestBody->getBoundary(); + $this->requestBody->rewind(); + } + + if (in_array($this->request->getMethod(), self::$bodyDisallowed) + || 0 == $this->contentLength + ) { + // No body: send a Content-Length header nonetheless (request #12900), + // but do that only for methods that require a body (bug #14740) + if (in_array($this->request->getMethod(), self::$bodyRequired)) { + $headers'content-length' = 0; + } else { + unset($headers'content-length'); + // if the method doesn't require a body and doesn't have a + // body, don't send a Content-Type header. (request #16799) + unset($headers'content-type'); + } + } else { + if (empty($headers'content-type')) { + $headers'content-type' = 'application/x-www-form-urlencoded'; + } + // Content-Length should not be sent for chunked Transfer-Encoding (bug #20125) + if (!isset($headers'transfer-encoding')) { + $headers'content-length' = $this->contentLength; + } + } + } +} +?>
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/Adapter/Curl.php
Added
@@ -0,0 +1,592 @@ +<?php +/** + * Adapter for HTTP_Request2 wrapping around cURL extension + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ +require_once 'HTTP/Request2/Adapter.php'; + +/** + * Adapter for HTTP_Request2 wrapping around cURL extension + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter +{ + /** + * Mapping of header names to cURL options + * + * @var array + */ + protected static $headerMap = + 'accept-encoding' => CURLOPT_ENCODING, + 'cookie' => CURLOPT_COOKIE, + 'referer' => CURLOPT_REFERER, + 'user-agent' => CURLOPT_USERAGENT + ; + + /** + * Mapping of SSL context options to cURL options + * + * @var array + */ + protected static $sslContextMap = + 'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER, + 'ssl_cafile' => CURLOPT_CAINFO, + 'ssl_capath' => CURLOPT_CAPATH, + 'ssl_local_cert' => CURLOPT_SSLCERT, + 'ssl_passphrase' => CURLOPT_SSLCERTPASSWD + ; + + /** + * Mapping of CURLE_* constants to Exception subclasses and error codes + * + * @var array<int, array{0: class-string<HTTP_Request2_Exception>, 1?: int}> + */ + protected static $errorMap = + CURLE_UNSUPPORTED_PROTOCOL => HTTP_Request2_MessageException::class, + HTTP_Request2_Exception::NON_HTTP_REDIRECT, + CURLE_COULDNT_RESOLVE_PROXY => HTTP_Request2_ConnectionException::class, + CURLE_COULDNT_RESOLVE_HOST => HTTP_Request2_ConnectionException::class, + CURLE_COULDNT_CONNECT => HTTP_Request2_ConnectionException::class, + // error returned from write callback + CURLE_WRITE_ERROR => HTTP_Request2_MessageException::class, + HTTP_Request2_Exception::NON_HTTP_REDIRECT, + CURLE_OPERATION_TIMEOUTED => HTTP_Request2_MessageException::class, + HTTP_Request2_Exception::TIMEOUT, + CURLE_HTTP_RANGE_ERROR => HTTP_Request2_MessageException::class, + CURLE_SSL_CONNECT_ERROR => HTTP_Request2_ConnectionException::class, + CURLE_LIBRARY_NOT_FOUND => HTTP_Request2_LogicException::class, + HTTP_Request2_Exception::MISCONFIGURATION, + CURLE_FUNCTION_NOT_FOUND => HTTP_Request2_LogicException::class, + HTTP_Request2_Exception::MISCONFIGURATION, + CURLE_ABORTED_BY_CALLBACK => HTTP_Request2_MessageException::class, + HTTP_Request2_Exception::NON_HTTP_REDIRECT, + CURLE_TOO_MANY_REDIRECTS => HTTP_Request2_MessageException::class, + HTTP_Request2_Exception::TOO_MANY_REDIRECTS, + CURLE_SSL_PEER_CERTIFICATE => HTTP_Request2_ConnectionException::class, + CURLE_GOT_NOTHING => HTTP_Request2_MessageException::class, + CURLE_SSL_ENGINE_NOTFOUND => HTTP_Request2_LogicException::class, + HTTP_Request2_Exception::MISCONFIGURATION, + CURLE_SSL_ENGINE_SETFAILED => HTTP_Request2_LogicException::class, + HTTP_Request2_Exception::MISCONFIGURATION, + CURLE_SEND_ERROR => HTTP_Request2_MessageException::class, + CURLE_RECV_ERROR => HTTP_Request2_MessageException::class, + CURLE_SSL_CERTPROBLEM => HTTP_Request2_LogicException::class, + HTTP_Request2_Exception::INVALID_ARGUMENT, + CURLE_SSL_CIPHER => HTTP_Request2_ConnectionException::class, + CURLE_BAD_CONTENT_ENCODING => HTTP_Request2_MessageException::class, + ; + + /** + * Response being received + * + * @var HTTP_Request2_Response|null + */ + protected $response; + + /** + * Whether 'sentHeaders' event was sent to observers + * + * @var boolean + */ + protected $eventSentHeaders = false; + + /** + * Whether 'receivedHeaders' event was sent to observers + * + * @var boolean + */ + protected $eventReceivedHeaders = false; + + /** + * Whether 'sentBoody' event was sent to observers + * + * @var boolean + */ + protected $eventSentBody = false; + + /** + * Position within request body + * + * @var integer + * @see callbackReadBody() + */ + protected $position = 0; + + /** + * Information about last transfer, as returned by curl_getinfo() + * + * @var array + */ + protected $lastInfo; + + /** + * Creates a subclass of HTTP_Request2_Exception from curl error data + * + * @param resource $ch curl handle + * + * @return HTTP_Request2_Exception + */ + protected static function wrapCurlError($ch) + { + $nativeCode = curl_errno($ch); + $message = 'Curl error: ' . curl_error($ch); + if (!isset(self::$errorMap$nativeCode)) { + return new HTTP_Request2_Exception($message, 0, $nativeCode); + } else { + $class = self::$errorMap$nativeCode0; + $code = empty(self::$errorMap$nativeCode1) + ? 0 : self::$errorMap$nativeCode1; + return new $class($message, $code, $nativeCode); + } + } + + /** + * Sends request to the remote server and returns its response + * + * @param HTTP_Request2 $request HTTP request message + * + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + */ + public function sendRequest(HTTP_Request2 $request) + { + if (!extension_loaded('curl')) { + throw new HTTP_Request2_LogicException( + 'cURL extension not available', HTTP_Request2_Exception::MISCONFIGURATION + ); + } + // These constants have the same value for cURL >= 7.62.0 + if (CURLE_SSL_CACERT !== CURLE_SSL_PEER_CERTIFICATE) { + self::$errorMapCURLE_SSL_CACERT = HTTP_Request2_ConnectionException::class; + } + + $this->request = $request; + $this->response = null; + $this->position = 0; + $this->eventSentHeaders = false; + $this->eventReceivedHeaders = false; + $this->eventSentBody = false; + + try { + if (false === curl_exec($ch = $this->createCurlHandle())) { + throw self::wrapCurlError($ch); + } + } finally { + if (isset($ch)) {
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/Adapter/Mock.php
Added
@@ -0,0 +1,167 @@ +<?php +/** + * Mock adapter intended for testing + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ +require_once 'HTTP/Request2/Adapter.php'; + +/** + * Mock adapter intended for testing + * + * Can be used to test applications depending on HTTP_Request2 package without + * actually performing any HTTP requests. This adapter will return responses + * previously added via addResponse() + * <code> + * $mock = new HTTP_Request2_Adapter_Mock(); + * $mock->addResponse("HTTP/1.1 ... "); + * + * $request = new HTTP_Request2(); + * $request->setAdapter($mock); + * + * // This will return the response set above + * $response = $req->send(); + * </code> + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter +{ + /** + * A queue of responses to be returned by sendRequest() + * + * @var array<int, array{HTTP_Request2_Response|Exception, ?string}> + */ + protected $responses = ; + + /** + * Returns the next response from the queue built by addResponse() + * + * Only responses without explicit URLs or with URLs equal to request URL + * will be considered. If matching response is not found or the queue is + * empty then default empty response with status 400 will be returned, + * if an Exception object was added to the queue it will be thrown. + * + * @param HTTP_Request2 $request HTTP request message + * + * @return HTTP_Request2_Response + * @throws Exception + */ + public function sendRequest(HTTP_Request2 $request) + { + $requestUrl = (string)$request->getUrl(); + $response = null; + foreach ($this->responses as $k => $v) { + if (!$v1 || $requestUrl == $v1) { + $response = $v0; + array_splice($this->responses, $k, 1); + break; + } + } + + if ($response instanceof HTTP_Request2_Response) { + return $response; + } elseif ($response instanceof Exception) { + // rethrow the exception + $class = get_class($response); + $message = $response->getMessage(); + $code = $response->getCode(); + throw new $class($message, $code); + } else { + return self::createResponseFromString("HTTP/1.1 400 Bad Request\r\n\r\n"); + } + } + + /** + * Adds response to the queue + * + * @param mixed $response either a string, a pointer to an open file, + * an instance of HTTP_Request2_Response or Exception + * @param string $url A request URL this response should be valid for + * (see {@link http://pear.php.net/bugs/bug.php?id=19276}) + * + * @return void + * @throws HTTP_Request2_Exception + */ + public function addResponse($response, $url = null) + { + if (is_string($response)) { + $response = self::createResponseFromString($response); + } elseif (is_resource($response)) { + $response = self::createResponseFromFile($response); + } elseif (!$response instanceof HTTP_Request2_Response + && !$response instanceof Exception + ) { + throw new HTTP_Request2_Exception('Parameter is not a valid response'); + } + $this->responses = $response, $url; + } + + /** + * Creates a new HTTP_Request2_Response object from a string + * + * @param string $str string containing HTTP response message + * + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + */ + public static function createResponseFromString($str) + { + $parts = preg_split('!(\r?\n){2}!m', $str, 2); + $headerLines = explode("\n", $parts0); + $response = new HTTP_Request2_Response(array_shift($headerLines)); + foreach ($headerLines as $headerLine) { + $response->parseHeaderLine($headerLine); + } + $response->parseHeaderLine(''); + if (isset($parts1)) { + $response->appendBody($parts1); + } + return $response; + } + + /** + * Creates a new HTTP_Request2_Response object from a file + * + * @param resource $fp file pointer returned by fopen() + * + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + */ + public static function createResponseFromFile($fp) + { + $response = new HTTP_Request2_Response(fgets($fp)); + do { + $headerLine = fgets($fp); + $response->parseHeaderLine($headerLine); + } while ('' != trim($headerLine)); + + while (!feof($fp)) { + $response->appendBody(fread($fp, 8192)); + } + return $response; + } +} +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/Adapter/Socket.php
Added
@@ -0,0 +1,1156 @@ +<?php +/** + * Socket-based adapter for HTTP_Request2 + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 */ +require_once 'HTTP/Request2/Adapter.php'; + +/** Socket wrapper class */ +require_once 'HTTP/Request2/SocketWrapper.php'; + +/** + * Socket-based adapter for HTTP_Request2 + * + * This adapter uses only PHP sockets and will work on almost any PHP + * environment. Code is based on original HTTP_Request PEAR package. + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter +{ + /** + * Regular expression for 'token' rule from RFC 2616 + */ + const REGEXP_TOKEN = '^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\\?={}\s+'; + + /** + * Regular expression for 'quoted-string' rule from RFC 2616 + */ + const REGEXP_QUOTED_STRING = '"(?>^"\\\\+|\\\\.)*"'; + + /** + * Connected sockets, needed for Keep-Alive support + * + * @var HTTP_Request2_SocketWrapper + * @see connect() + */ + protected static $sockets = ; + + /** + * Data for digest authentication scheme + * + * The keys for the array are URL prefixes. + * + * The values are associative arrays with data (realm, nonce, nonce-count, + * opaque...) needed for digest authentication. Stored here to prevent making + * duplicate requests to digest-protected resources after we have already + * received the challenge. + * + * @var array + */ + protected static $challenges = ; + + /** + * Connected socket + * + * @var HTTP_Request2_SocketWrapper + * @see connect() + */ + protected $socket; + + /** + * Challenge used for server digest authentication + * + * @var array + */ + protected $serverChallenge; + + /** + * Challenge used for proxy digest authentication + * + * @var array + */ + protected $proxyChallenge; + + /** + * Remaining length of the current chunk, when reading chunked response + * + * @var integer + * @see readChunked() + */ + protected $chunkLength = 0; + + /** + * Remaining amount of redirections to follow + * + * Starts at 'max_redirects' configuration parameter and is reduced on each + * subsequent redirect. An Exception will be thrown once it reaches zero. + * + * @var int|null + */ + 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 + * + * @param HTTP_Request2 $request HTTP request message + * + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + */ + public function sendRequest(HTTP_Request2 $request) + { + $this->request = $request; + + try { + $keepAlive = $this->connect(); + $headers = $this->prepareHeaders(); + $this->socket->write($headers); + // provide request headers to the observer, see request #7633 + $this->request->setLastEvent('sentHeaders', $headers); + + if (!$this->expect100Continue) { + $this->writeBody(); + $response = $this->readResponse(); + + } else { + $response = $this->readResponse(); + if (null === $response || 100 === $response->getStatus()) { + $this->expect100Continue = false; + // either got "100 Continue" or timed out -> send body + $this->writeBody(); + $response = $this->readResponse(); + } + } + + // If no exceptions were thrown, $response should be available here + /** @var HTTP_Request2_Response $response */ + if ($jar = $request->getCookieJar()) { + $jar->addCookiesFromResponse($response); + } + + if (!$this->canKeepAlive($keepAlive, $response)) { + $this->disconnect(); + } + + if ($this->shouldUseProxyDigestAuth($response)) { + return $this->sendRequest($request); + } + if ($this->shouldUseServerDigestAuth($response)) { + return $this->sendRequest($request); + } + if ($authInfo = $response->getHeader('authentication-info')) { + $this->updateChallenge($this->serverChallenge, $authInfo); + } + if ($proxyInfo = $response->getHeader('proxy-authentication-info')) { + $this->updateChallenge($this->proxyChallenge, $proxyInfo); + } + + } catch (Exception $e) { + $this->disconnect(); + $this->redirectCountdown = null; + throw $e; + + } finally { + unset($this->request, $this->requestBody); + } + + if (!$request->getConfig('follow_redirects') || !$response->isRedirect()) { + $this->redirectCountdown = null; + return $response; + } else { + return $this->handleRedirect($request, $response); + } + } + + /** + * Connects to the remote server + * + * @return bool whether the connection can be persistent + * @throws HTTP_Request2_Exception + */
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/ConnectionException.php
Added
@@ -0,0 +1,38 @@ +<?php +/** + * Exception classes for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 thrown when connection to a web or proxy server fails + * + * The exception will not contain a package error code, but will contain + * native error code, as returned by stream_socket_client() or curl_errno(). + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception +{ +} + +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/CookieJar.php
Added
@@ -0,0 +1,581 @@ +<?php +/** + * Stores cookies and passes them between HTTP requests + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 */ +require_once 'HTTP/Request2.php'; + +/** + * Stores cookies and passes them between HTTP requests + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: @package_version@ + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_CookieJar implements Serializable +{ + /** + * Array of stored cookies + * + * The array is indexed by domain, path and cookie name + * .example.com + * / + * some_cookie => cookie data + * /subdir + * other_cookie => cookie data + * .example.org + * ... + * + * @var array + */ + protected $cookies = ; + + /** + * Whether session cookies should be serialized when serializing the jar + * + * @var bool + */ + protected $serializeSession = false; + + /** + * Whether Public Suffix List should be used for domain matching + * + * @var bool + */ + protected $useList = true; + + /** + * Whether an attempt to store an invalid cookie should be ignored, rather than cause an Exception + * + * @var bool + */ + protected $ignoreInvalid = false; + + /** + * Array with Public Suffix List data + * + * @var array + * @link http://publicsuffix.org/ + */ + protected static $psl = ; + + /** + * Class constructor, sets various options + * + * @param bool $serializeSessionCookies Controls serializing session cookies, + * see {@link serializeSessionCookies()} + * @param bool $usePublicSuffixList Controls using Public Suffix List, + * see {@link usePublicSuffixList()} + * @param bool $ignoreInvalidCookies Whether invalid cookies should be ignored, + * see {@link ignoreInvalidCookies()} + */ + public function __construct( + $serializeSessionCookies = false, $usePublicSuffixList = true, + $ignoreInvalidCookies = false + ) { + $this->serializeSessionCookies($serializeSessionCookies); + $this->usePublicSuffixList($usePublicSuffixList); + $this->ignoreInvalidCookies($ignoreInvalidCookies); + } + + /** + * Returns current time formatted in ISO-8601 at UTC timezone + * + * @return string + */ + protected function now() + { + $dt = new DateTime(); + $dt->setTimezone(new DateTimeZone('UTC')); + return $dt->format(DateTime::ISO8601); + } + + /** + * Checks cookie array for correctness, possibly updating its 'domain', 'path' and 'expires' fields + * + * The checks are as follows: + * - cookie array should contain 'name' and 'value' fields; + * - name and value should not contain disallowed symbols; + * - 'expires' should be either empty parseable by DateTime; + * - 'domain' and 'path' should be either not empty or an URL where + * cookie was set should be provided. + * - if $setter is provided, then document at that URL should be allowed + * to set a cookie for that 'domain'. If $setter is not provided, + * then no domain checks will be made. + * + * 'expires' field will be converted to ISO8601 format from COOKIE format, + * 'domain' and 'path' will be set from setter URL if empty. + * + * @param array $cookie cookie data, as returned by + * {@link HTTP_Request2_Response::getCookies()} + * @param Net_URL2 $setter URL of the document that sent Set-Cookie header + * + * @return array Updated cookie array + * @throws HTTP_Request2_LogicException + * @throws HTTP_Request2_MessageException + */ + protected function checkAndUpdateFields(array $cookie, Net_URL2 $setter = null) + { + if ($missing = array_diff('name', 'value', array_keys($cookie))) { + throw new HTTP_Request2_LogicException( + "Cookie array should contain 'name' and 'value' fields", + HTTP_Request2_Exception::MISSING_VALUE + ); + } + if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie'name')) { + throw new HTTP_Request2_LogicException( + "Invalid cookie name: '{$cookie'name'}'", + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + if (preg_match(HTTP_Request2::REGEXP_INVALID_COOKIE, $cookie'value')) { + throw new HTTP_Request2_LogicException( + "Invalid cookie value: '{$cookie'value'}'", + HTTP_Request2_Exception::INVALID_ARGUMENT + ); + } + $cookie += 'domain' => '', 'path' => '', 'expires' => null, 'secure' => false; + + // Need ISO-8601 date @ UTC timezone + if (!empty($cookie'expires') + && !preg_match('/^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\+0000$/', $cookie'expires') + ) { + try { + $dt = new DateTime($cookie'expires'); + $dt->setTimezone(new DateTimeZone('UTC')); + $cookie'expires' = $dt->format(DateTime::ISO8601); + } catch (Exception $e) { + throw new HTTP_Request2_LogicException($e->getMessage()); + } + } + + if (empty($cookie'domain') || empty($cookie'path')) { + if (!$setter) { + throw new HTTP_Request2_LogicException( + 'Cookie misses domain and/or path component, cookie setter URL needed', + HTTP_Request2_Exception::MISSING_VALUE + ); + } + if (empty($cookie'domain')) { + if ($host = $setter->getHost()) { + $cookie'domain' = (string)$host; + } else { + throw new HTTP_Request2_LogicException( + 'Setter URL does not contain host part, can\'t set cookie domain', + HTTP_Request2_Exception::MISSING_VALUE + ); + } + } + if (empty($cookie'path')) { + $path = $setter->getPath(); + $cookie'path' = empty($path) + ? '/' + : substr($path, 0, (int)strrpos($path, '/') + 1); + } + } + + if ($setter && !$this->domainMatch((string)$setter->getHost(), $cookie'domain')) { + throw new HTTP_Request2_MessageException( + "Domain " . $setter->getHost() . " cannot set cookies for " + . $cookie'domain'
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/Exception.php
Added
@@ -0,0 +1,118 @@ +<?php +/** + * Exception classes for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 exceptions in PEAR + */ +require_once 'PEAR/Exception.php'; + +/** + * Base exception class for HTTP_Request2 package + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=132 + */ +class HTTP_Request2_Exception extends PEAR_Exception +{ + /** + * An invalid argument was passed to a method + */ + const INVALID_ARGUMENT = 1; + /** + * Some required value was not available + */ + const MISSING_VALUE = 2; + /** + * Request cannot be processed due to errors in PHP configuration + */ + const MISCONFIGURATION = 3; + /** + * Error reading the local file + */ + const READ_ERROR = 4; + + /** + * Server returned a response that does not conform to HTTP protocol + */ + const MALFORMED_RESPONSE = 10; + /** + * Failure decoding Content-Encoding or Transfer-Encoding of response + */ + const DECODE_ERROR = 20; + /** + * Operation timed out + */ + const TIMEOUT = 30; + /** + * Number of redirects exceeded 'max_redirects' configuration parameter + */ + const TOO_MANY_REDIRECTS = 40; + /** + * Redirect to a protocol other than http(s):// + */ + const NON_HTTP_REDIRECT = 50; + + /** + * Native error code + * + * @var int|null + */ + private $_nativeCode; + + /** + * Constructor, can set package error code and native error code + * + * @param string $message exception message + * @param int $code package error code, one of class constants + * @param int $nativeCode error code from underlying PHP extension + */ + public function __construct($message = '', $code = null, $nativeCode = null) + { + parent::__construct($message, $code); + $this->_nativeCode = $nativeCode; + } + + /** + * Returns error code produced by underlying PHP extension + * + * For Socket Adapter this may contain error number returned by + * stream_socket_client(), for Curl Adapter this will contain error number + * returned by curl_errno() + * + * @return int|null + */ + public function getNativeCode() + { + return $this->_nativeCode; + } +} + +// backwards compatibility, include the child exceptions if installed with PEAR installer +require_once 'HTTP/Request2/ConnectionException.php'; +require_once 'HTTP/Request2/LogicException.php'; +require_once 'HTTP/Request2/MessageException.php'; +require_once 'HTTP/Request2/NotImplementedException.php'; + +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/LogicException.php
Added
@@ -0,0 +1,42 @@ +<?php +/** + * Exception classes for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 that represents error in the program logic + * + * This exception usually implies a programmer's error, like passing invalid + * data to methods or trying to use PHP extensions that weren't installed or + * enabled. Usually exceptions of this kind will be thrown before request even + * starts. + * + * The exception will usually contain a package error code. + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_LogicException extends HTTP_Request2_Exception +{ +} + +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/MessageException.php
Added
@@ -0,0 +1,37 @@ +<?php +/** + * Exception classes for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 thrown when sending or receiving HTTP message fails + * + * The exception may contain both package error code and native error code. + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_MessageException extends HTTP_Request2_Exception +{ +} + +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/MultipartBody.php
Added
@@ -0,0 +1,275 @@ +<?php +/** + * Helper class for building multipart/form-data request body + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + * + * The class helps to reduce memory consumption by streaming large file uploads + * from disk, it also allows monitoring of upload progress (see request #7630) + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + * @link http://tools.ietf.org/html/rfc1867 + */ +class HTTP_Request2_MultipartBody +{ + /** + * MIME boundary + * + * @var string + */ + private $_boundary; + + /** + * Form parameters added via {@link HTTP_Request2::addPostParameter()} + * + * @var array + */ + private $_params = ; + + /** + * File uploads added via {@link HTTP_Request2::addUpload()} + * + * @var array + */ + private $_uploads = ; + + /** + * Header for parts with parameters + * + * @var string + */ + private $_headerParam = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n"; + + /** + * Header for parts with uploads + * + * @var string + */ + private $_headerUpload = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\nContent-Type: %s\r\n\r\n"; + + /** + * Current position in parameter and upload arrays + * + * First number is index of "current" part, second number is position within + * "current" part + * + * @var array + */ + private $_pos = 0, 0; + + + /** + * Constructor. Sets the arrays with POST data. + * + * @param array $params values of form fields set via + * {@link HTTP_Request2::addPostParameter()} + * @param array $uploads file uploads set via + * {@link HTTP_Request2::addUpload()} + * @param bool $useBrackets whether to append brackets to array variable names + */ + public function __construct(array $params, array $uploads, $useBrackets = true) + { + $this->_params = self::_flattenArray('', $params, $useBrackets); + foreach ($uploads as $fieldName => $f) { + if (!is_array($f'fp')) { + $this->_uploads = $f + 'name' => $fieldName; + } else { + for ($i = 0; $i < count($f'fp'); $i++) { + $upload = + 'name' => ($useBrackets? $fieldName . '' . $i . '': $fieldName) + ; + foreach ('fp', 'filename', 'size', 'type' as $key) { + $upload$key = $f$key$i; + } + $this->_uploads = $upload; + } + } + } + } + + /** + * Returns the length of the body to use in Content-Length header + * + * @return integer + */ + public function getLength() + { + $boundaryLength = strlen($this->getBoundary()); + $headerParamLength = strlen($this->_headerParam) - 4 + $boundaryLength; + $headerUploadLength = strlen($this->_headerUpload) - 8 + $boundaryLength; + $length = $boundaryLength + 6; + foreach ($this->_params as $p) { + $length += $headerParamLength + strlen($p0) + strlen($p1) + 2; + } + foreach ($this->_uploads as $u) { + $length += $headerUploadLength + strlen($u'name') + strlen($u'type') + + strlen($u'filename') + $u'size' + 2; + } + return $length; + } + + /** + * Returns the boundary to use in Content-Type header + * + * @return string + */ + public function getBoundary() + { + if (empty($this->_boundary)) { + $this->_boundary = '--' . md5('PEAR-HTTP_Request2-' . microtime()); + } + return $this->_boundary; + } + + /** + * Returns next chunk of request body + * + * @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) + { + $ret = ''; + $boundary = $this->getBoundary(); + $paramCount = count($this->_params); + $uploadCount = count($this->_uploads); + while ($length > 0 && $this->_pos0 <= $paramCount + $uploadCount) { + $oldLength = $length; + if ($this->_pos0 < $paramCount) { + $param = sprintf( + $this->_headerParam, $boundary, $this->_params$this->_pos00 + ) . $this->_params$this->_pos01 . "\r\n"; + $ret .= substr($param, $this->_pos1, $length); + $length -= min(strlen($param) - $this->_pos1, $length); + + } elseif ($this->_pos0 < $paramCount + $uploadCount) { + $pos = $this->_pos0 - $paramCount; + $header = sprintf( + $this->_headerUpload, $boundary, $this->_uploads$pos'name', + $this->_uploads$pos'filename', $this->_uploads$pos'type' + ); + if ($this->_pos1 < strlen($header)) { + $ret .= substr($header, $this->_pos1, $length); + $length -= min(strlen($header) - $this->_pos1, $length); + } + $filePos = max(0, $this->_pos1 - strlen($header)); + 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->_pos1 + ($oldLength - $length) - + strlen($header) - $this->_uploads$pos'size'; + $ret .= substr("\r\n", $start, $length); + $length -= min(2 - $start, $length); + }
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/NotImplementedException.php
Added
@@ -0,0 +1,35 @@ +<?php +/** + * Exception classes for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 thrown in case of missing features + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception +{ +} + +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/Observer/Log.php
Added
@@ -0,0 +1,198 @@ +<?php +/** + * An observer useful for debugging / testing. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author David Jean Louis <izi@php.net> + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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'; + +/** + * A debug observer useful for debugging / testing. + * + * This observer logs to a log target data corresponding to the various request + * and response events, it logs by default to php://output but can be configured + * to log to a file or via the PEAR Log package. + * + * A simple example: + * <code> + * require_once 'HTTP/Request2.php'; + * require_once 'HTTP/Request2/Observer/Log.php'; + * + * $request = new HTTP_Request2('http://www.example.com'); + * $observer = new HTTP_Request2_Observer_Log(); + * $request->attach($observer); + * $request->send(); + * </code> + * + * A more complex example with PEAR Log: + * <code> + * require_once 'HTTP/Request2.php'; + * require_once 'HTTP/Request2/Observer/Log.php'; + * require_once 'Log.php'; + * + * $request = new HTTP_Request2('http://www.example.com'); + * // we want to log with PEAR log + * $observer = new HTTP_Request2_Observer_Log(Log::factory('console')); + * + * // we only want to log received headers + * $observer->events = array('receivedHeaders'); + * + * $request->attach($observer); + * $request->send(); + * </code> + * + * @category HTTP + * @package HTTP_Request2 + * @author David Jean Louis <izi@php.net> + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_Observer_Log implements SplObserver +{ + // properties {{{ + + /** + * The log target, it can be a resource or a PEAR Log instance. + * + * @var resource|Log $target + */ + protected $target; + + /** + * The events to log. + * + * @var array $events + */ + public $events = + 'connect', + 'sentHeaders', + 'sentBody', + 'receivedHeaders', + 'receivedBody', + 'disconnect', + ; + + // }}} + // __construct() {{{ + + /** + * Constructor. + * + * @param string|resource|Log $target Can be a file path (default: php://output), a resource, + * or an instance of the PEAR Log class. + * @param array $events Array of events to listen to (default: all events) + * + * @return void + */ + public function __construct($target = 'php://output', array $events = ) + { + if (!empty($events)) { + $this->events = $events; + } + if (is_resource($target) || $target instanceof Log) { + $this->target = $target; + } elseif (false === ($this->target = @fopen($target, 'ab'))) { + throw new HTTP_Request2_Exception("Unable to open '{$target}'"); + } + } + + // }}} + // update() {{{ + + #ReturnTypeWillChange + /** + * Called when the request notifies us of an event. + * + * @param HTTP_Request2 $subject The HTTP_Request2 instance + * + * @return void + */ + public function update(SplSubject $subject) + { + if (!$subject instanceof HTTP_Request2) { + return; + } + $event = $subject->getLastEvent(); + if (!in_array($event'name', $this->events)) { + return; + } + + switch ($event'name') { + case 'connect': + $this->log('* Connected to ' . $event'data'); + break; + case 'sentHeaders': + $headers = explode("\r\n", $event'data'); + array_pop($headers); + foreach ($headers as $header) { + $this->log('> ' . $header); + } + break; + case 'sentBody': + $this->log('> ' . $event'data' . ' byte(s) sent'); + break; + case 'receivedHeaders': + $this->log( + sprintf( + '< HTTP/%s %s %s', $event'data'->getVersion(), + $event'data'->getStatus(), $event'data'->getReasonPhrase() + ) + ); + $headers = $event'data'->getHeader(); + foreach ($headers as $key => $val) { + $this->log('< ' . $key . ': ' . $val); + } + $this->log('< '); + break; + case 'receivedBody': + $this->log($event'data'->getBody()); + break; + case 'disconnect': + $this->log('* Disconnected'); + break; + } + } + + // }}} + // log() {{{ + + /** + * Logs the given message to the configured target. + * + * @param string $message Message to display + * + * @return void + */ + protected function log($message) + { + if ($this->target instanceof Log) { + $this->target->debug($message); + } elseif (is_resource($this->target)) { + fwrite($this->target, $message . "\r\n"); + } + } + + // }}} +} + +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/Observer/UncompressingDownload.php
Added
@@ -0,0 +1,278 @@ +<?php +/** + * An observer that saves response body to stream, possibly uncompressing it + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Delian Krustev <krustev@krustev.net> + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +require_once 'HTTP/Request2/Response.php'; + +/** + * An observer that saves response body to stream, possibly uncompressing it + * + * This Observer is written in compliment to pear's HTTP_Request2 in order to + * avoid reading the whole response body in memory. Instead it writes the body + * to a stream. If the body is transferred with content-encoding set to + * "deflate" or "gzip" it is decoded on the fly. + * + * The constructor accepts an already opened (for write) stream (file_descriptor). + * If the response is deflate/gzip encoded a "zlib.inflate" filter is applied + * to the stream. When the body has been read from the request and written to + * the stream ("receivedBody" event) the filter is removed from the stream. + * + * The "zlib.inflate" filter works fine with pure "deflate" encoding. It does + * not understand the "deflate+zlib" and "gzip" headers though, so they have to + * be removed prior to being passed to the stream. This is done in the "update" + * method. + * + * It is also possible to limit the size of written extracted bytes by passing + * "max_bytes" to the constructor. This is important because e.g. 1GB of + * zeroes take about a MB when compressed. + * + * Exceptions are being thrown if data could not be written to the stream or + * the written bytes have already exceeded the requested maximum. If the "gzip" + * header is malformed or could not be parsed an exception will be thrown too. + * + * Example usage follows: + * + * <code> + * require_once 'HTTP/Request2.php'; + * require_once 'HTTP/Request2/Observer/UncompressingDownload.php'; + * + * #$inPath = 'http://carsten.codimi.de/gzip.yaws/daniels.html'; + * #$inPath = 'http://carsten.codimi.de/gzip.yaws/daniels.html?deflate=on'; + * $inPath = 'http://carsten.codimi.de/gzip.yaws/daniels.html?deflate=on&zlib=on'; + * #$outPath = "/dev/null"; + * $outPath = "delme"; + * + * $stream = fopen($outPath, 'wb'); + * if (!$stream) { + * throw new Exception('fopen failed'); + * } + * + * $request = new HTTP_Request2( + * $inPath, + * HTTP_Request2::METHOD_GET, + * array( + * 'store_body' => false, + * 'connect_timeout' => 5, + * 'timeout' => 10, + * 'ssl_verify_peer' => true, + * 'ssl_verify_host' => true, + * 'ssl_cafile' => null, + * 'ssl_capath' => '/etc/ssl/certs', + * 'max_redirects' => 10, + * 'follow_redirects' => true, + * 'strict_redirects' => false + * ) + * ); + * + * $observer = new HTTP_Request2_Observer_UncompressingDownload($stream, 9999999); + * $request->attach($observer); + * + * $response = $request->send(); + * + * fclose($stream); + * echo "OK\n"; + * </code> + * + * @category HTTP + * @package HTTP_Request2 + * @author Delian Krustev <krustev@krustev.net> + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + */ +class HTTP_Request2_Observer_UncompressingDownload implements SplObserver +{ + /** + * The stream to write response body to + * + * @var resource + */ + private $_stream; + + /** + * 'zlib.inflate' filter possibly added to stream + * + * @var resource|null + */ + private $_streamFilter; + + /** + * The value of response's Content-Encoding header + * + * @var string + */ + private $_encoding; + + /** + * Whether the observer is still waiting for gzip/deflate header + * + * @var bool + */ + private $_processingHeader = true; + + /** + * Starting position in the stream observer writes to + * + * @var int + */ + private $_startPosition = 0; + + /** + * Maximum bytes to write + * + * @var int|null + */ + private $_maxDownloadSize; + + /** + * Whether response being received is a redirect + * + * @var bool + */ + private $_redirect = false; + + /** + * Accumulated body chunks that may contain (gzip) header + * + * @var string + */ + private $_possibleHeader = ''; + + /** + * Class constructor + * + * Note that there might be problems with max_bytes and files bigger + * than 2 GB on 32bit platforms + * + * @param resource $stream a stream (or file descriptor) opened for writing. + * @param int $maxDownloadSize maximum bytes to write + */ + public function __construct($stream, $maxDownloadSize = null) + { + $this->_stream = $stream; + if ($maxDownloadSize) { + $this->_maxDownloadSize = $maxDownloadSize; + $this->_startPosition = ftell($this->_stream); + } + } + + #ReturnTypeWillChange + /** + * Called when the request notifies us of an event. + * + * @param HTTP_Request2 $subject The HTTP_Request2 instance + * + * @return void + * @throws HTTP_Request2_MessageException + */ + public function update(SplSubject $subject) + { + if (!$subject instanceof HTTP_Request2) { + return; + } + $event = $subject->getLastEvent(); + $encoded = false; + + /* @var $event'data' HTTP_Request2_Response */ + switch ($event'name') { + case 'receivedHeaders': + $this->_processingHeader = true; + $this->_redirect = $event'data'->isRedirect(); + $this->_encoding = strtolower($event'data'->getHeader('content-encoding') ?: '');
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/Response.php
Added
@@ -0,0 +1,694 @@ +<?php +/** + * Class representing a HTTP response + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 representing a HTTP response + * + * The class is designed to be used in "streaming" scenario, building the + * response as it is being received: + * <code> + * $statusLine = read_status_line(); + * $response = new HTTP_Request2_Response($statusLine); + * do { + * $headerLine = read_header_line(); + * $response->parseHeaderLine($headerLine); + * } while ($headerLine != ''); + * + * while ($chunk = read_body()) { + * $response->appendBody($chunk); + * } + * + * var_dump($response->getHeader(), $response->getCookies(), $response->getBody()); + * </code> + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @link http://pear.php.net/package/HTTP_Request2 + * @link http://tools.ietf.org/html/rfc2616#section-6 + */ +class HTTP_Request2_Response +{ + /** + * HTTP protocol version (e.g. 1.0, 1.1) + * + * @var string + */ + protected $version; + + /** + * Status code + * + * @var integer + * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 + */ + protected $code; + + /** + * Reason phrase + * + * @var string|null + * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 + */ + protected $reasonPhrase; + + /** + * Effective URL (may be different from original request URL in case of redirects) + * + * @var string + */ + protected $effectiveUrl; + + /** + * Associative array of response headers + * + * @var array + */ + protected $headers = ; + + /** + * Cookies set in the response + * + * @var array + */ + protected $cookies = ; + + /** + * Name of last header processed by {@see parseHeaderLine()} + * + * Used to handle the headers that span multiple lines + * + * @var string|null + */ + protected $lastHeader = null; + + /** + * Response body + * + * @var string + */ + protected $body = ''; + + /** + * Whether the body is still encoded by Content-Encoding + * + * cURL provides the decoded body to the callback; if we are reading from + * socket the body is still gzipped / deflated + * + * @var bool + */ + protected $bodyEncoded; + + /** + * Associative array of HTTP status code / reason phrase. + * + * @var array + * @link http://tools.ietf.org/html/rfc2616#section-10 + */ + protected static $phrases = + + // 1xx: Informational - Request received, continuing process + 100 => 'Continue', + 101 => 'Switching Protocols', + + // 2xx: Success - The action was successfully received, understood and + // accepted + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + + // 3xx: Redirection - Further action must be taken in order to complete + // the request + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Found', // 1.1 + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 307 => 'Temporary Redirect', + + // 4xx: Client Error - The request contains bad syntax or cannot be + // fulfilled + 400 => 'Bad Request', + 401 => 'Unauthorized', + 402 => 'Payment Required', + 403 => 'Forbidden', + 404 => 'Not Found', + 405 => 'Method Not Allowed', + 406 => 'Not Acceptable', + 407 => 'Proxy Authentication Required', + 408 => 'Request Timeout', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Long', + 415 => 'Unsupported Media Type', + 416 => 'Requested Range Not Satisfiable', + 417 => 'Expectation Failed', + + // 5xx: Server Error - The server failed to fulfill an apparently + // valid request + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Timeout', + 505 => 'HTTP Version Not Supported', + 509 => 'Bandwidth Limit Exceeded', + + ; + + /** + * Returns the default reason phrase for the given code or all reason phrases + * + * @param int $code Response code + * + * @return string|array|null Default reason phrase for $code if $code is given + * (null if no phrase is available), array of all + * reason phrases if $code is null + * @link http://pear.php.net/bugs/18716
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/SOCKS5.php
Added
@@ -0,0 +1,138 @@ +<?php +/** + * SOCKS5 proxy connection class + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 */ +require_once 'HTTP/Request2/SocketWrapper.php'; + +/** + * SOCKS5 proxy connection class (used by Socket Adapter) + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @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 + */ +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 $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 $contextOptions = , + $username = '', $password = '' + ) { + parent::__construct($address, $timeout, $contextOptions); + + if ('' !== $username) { + $request = pack('C4', 5, 2, 0, 2); + } else { + $request = pack('C3', 5, 1, 0); + } + $this->write($request); + $response = unpack('Cversion/Cmethod', (string)$this->read(3)); + if (!$response || 5 !== $response'version') { + throw new HTTP_Request2_MessageException( + 'Invalid version received from SOCKS5 proxy: ' + . ($response ? $response'version' : 'none'), + HTTP_Request2_Exception::MALFORMED_RESPONSE + ); + } + switch ($response'method') { + case 2: + $this->performAuthentication($username, $password); + case 0: + break; + default: + throw new HTTP_Request2_ConnectionException( + "Connection rejected by proxy due to unsupported auth method" + ); + } + } + + /** + * Performs username/password authentication for SOCKS5 + * + * @param string $username Proxy user name + * @param string $password Proxy password + * + * @return void + * @throws HTTP_Request2_ConnectionException + * @throws HTTP_Request2_MessageException + * @link http://tools.ietf.org/html/rfc1929 + */ + protected function performAuthentication($username, $password) + { + $request = pack('C2', 1, strlen($username)) . $username + . pack('C', strlen($password)) . $password; + + $this->write($request); + $response = unpack('Cvn/Cstatus', (string)$this->read(3)); + if (!$response || 1 !== $response'vn' || 0 !== $response'status') { + throw new HTTP_Request2_ConnectionException( + 'Connection rejected by proxy due to invalid username and/or password' + ); + } + } + + /** + * Connects to a remote host via proxy + * + * @param string $remoteHost Remote host + * @param int $remotePort Remote port + * + * @return void + * @throws HTTP_Request2_ConnectionException + * @throws HTTP_Request2_MessageException + */ + public function connect($remoteHost, $remotePort) + { + $request = pack('C5', 0x05, 0x01, 0x00, 0x03, strlen($remoteHost)) + . $remoteHost . pack('n', $remotePort); + + $this->write($request); + $response = unpack('Cversion/Creply/Creserved', (string)$this->read(1024)); + if (!$response || 5 !== $response'version' || 0 !== $response'reserved') { + throw new HTTP_Request2_MessageException( + 'Invalid response received from SOCKS5 proxy', + HTTP_Request2_Exception::MALFORMED_RESPONSE + ); + } elseif (0 !== $response'reply') { + throw new HTTP_Request2_ConnectionException( + "Unable to connect to {$remoteHost}:{$remotePort} through SOCKS5 proxy", + 0, $response'reply' + ); + } + } +} +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/HTTP/Request2/SocketWrapper.php
Added
@@ -0,0 +1,393 @@ +<?php +/** + * Socket wrapper class used by Socket Adapter + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 */ +require_once 'HTTP/Request2/Exception.php'; + +/** + * Socket wrapper class used by Socket Adapter + * + * Needed to properly handle connection errors, global timeout support and + * similar things. Loosely based on Net_Socket used by older HTTP_Request. + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License + * @version Release: 2.6.0 + * @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 + */ +class HTTP_Request2_SocketWrapper +{ + /** + * PHP warning messages raised during stream_socket_client() call + * + * @var array + */ + protected $connectionWarnings = ; + + /** + * Connected socket + * + * @var resource + */ + protected $socket; + + /** + * Sum of start time and global timeout, exception will be thrown if request continues past this time + * + * @var float|null + */ + protected $deadline; + + /** + * Global timeout value, mostly for exception messages + * + * @var integer + */ + protected $timeout; + + /** + * 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 $contextOptions Context options + * + * @throws HTTP_Request2_LogicException + * @throws HTTP_Request2_ConnectionException + */ + public function __construct($address, $timeout, array $contextOptions = ) + { + if (!empty($contextOptions) + && !isset($contextOptions'socket') && !isset($contextOptions'ssl') + ) { + // Backwards compatibility with 2.1.0 and 2.1.1 releases + $contextOptions = 'ssl' => $contextOptions; + } + if (isset($contextOptions'ssl')) { + $cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; + if (defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT')) { + $cryptoMethod |= STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT; + } + $contextOptions'ssl' += + // Using "Intermediate compatibility" cipher bundle from + // https://wiki.mozilla.org/Security/Server_Side_TLS + 'ciphers' => 'TLS_AES_128_GCM_SHA256:' + . 'TLS_AES_256_GCM_SHA384:' + . 'TLS_CHACHA20_POLY1305_SHA256:' + . 'ECDHE-ECDSA-AES128-GCM-SHA256:' + . 'ECDHE-RSA-AES128-GCM-SHA256:' + . 'ECDHE-ECDSA-AES256-GCM-SHA384:' + . 'ECDHE-RSA-AES256-GCM-SHA384:' + . 'ECDHE-ECDSA-CHACHA20-POLY1305:' + . 'ECDHE-RSA-CHACHA20-POLY1305:' + . 'DHE-RSA-AES128-GCM-SHA256:' + . 'DHE-RSA-AES256-GCM-SHA384', + 'disable_compression' => true, + 'crypto_method' => $cryptoMethod + ; + } + $context = stream_context_create(); + 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($this, 'connectionWarningsHandler'); + $socket = stream_socket_client( + $address, $errno, $errstr, $timeout, STREAM_CLIENT_CONNECT, $context + ); + restore_error_handler(); + // 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 ($socket) { + fclose($socket); + } + $error = $errstr ?: implode("\n", $this->connectionWarnings); + throw new HTTP_Request2_ConnectionException( + "Unable to connect to {$address}. Error: {$error}", 0, $errno + ); + } + // Run socket in non-blocking mode, to prevent possible problems with + // HTTPS requests not timing out properly (see bug #21229) + $this->socket = $socket; + stream_set_blocking($this->socket, false); + } + + /** + * Destructor, disconnects socket + */ + public function __destruct() + { + fclose($this->socket); + } + + /** + * Wrapper around fread(), handles global request timeout + * + * @param int $length Reads up to this number of bytes + * + * @return string|false Data read from socket by fread() + * @throws HTTP_Request2_MessageException In case of timeout + */ + public function read($length) + { + // Looks like stream_select() may return true, but then fread() will return an empty string... + // For some reason or other happens mostly with servers behind Cloudflare. + // Let's do the fread() call in a loop until either an error/eof or non-empty string: + do { + $data = false; + $timeouts = $this->_getTimeoutsForStreamSelect(); + + $r = $this->socket; + $w = ; + $e = ; + if (stream_select($r, $w, $e, $timeouts0, $timeouts1)) { + $data = fread($this->socket, $length); + } + + $this->checkTimeout(); + } while ('' === $data && !$this->eof()); + + return $data; + } + + /** + * Reads until either the end of the socket or a newline, whichever comes first + * + * 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 $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, $localTimeout = null) + { + $line = ''; + while (!feof($this->socket)) {
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/data/generate-list.php
Added
@@ -0,0 +1,107 @@ +<?php +/** + * Helper file for downloading Public Suffix List and converting it to PHP array + * + * You can run this script to update PSL to the current version instead of + * waiting for a new release of HTTP_Request2. + * + * NB: peer validation is DISABLED when downloading. If you want to enable it, + * change ssl_verify_peer to true and provide CA file (see below) + */ + +/** URL to download Public Suffix List from */ +define('LIST_URL', 'https://publicsuffix.org/list/public_suffix_list.dat'); +/** Name of PHP file to write */ +define('OUTPUT_FILE', __DIR__ . '/public-suffix-list.php'); + +if (file_exists('../vendor/autoload.php')) { + require_once '../vendor/autoload.php'; +} else { + require_once 'HTTP/Request2.php'; +} + +function buildSubdomain(&$node, $tldParts) +{ + $part = trim(array_pop($tldParts)); + + if (!array_key_exists($part, $node)) { + $node$part = ; + } + + if (0 < count($tldParts)) { + buildSubdomain($node$part, $tldParts); + } +} + +function writeNode($fp, $valueTree, $key = null, $indent = 0) +{ + if (is_null($key)) { + fwrite($fp, "return "); + + } else { + fwrite($fp, str_repeat(' ', $indent) . "'$key' => "); + } + + if (0 == ($count = count($valueTree))) { + fwrite($fp, 'true'); + } else { + fwrite($fp, "\n"); + for ($keys = array_keys($valueTree), $i = 0; $i < $count; $i++) { + writeNode($fp, $valueTree$keys$i, $keys$i, $indent + 1); + if ($i + 1 != $count) { + fwrite($fp, ",\n"); + } else { + fwrite($fp, "\n"); + } + } + fwrite($fp, str_repeat(' ', $indent) . ""); + } +} + + +try { + $request = new HTTP_Request2(LIST_URL, HTTP_Request2::METHOD_GET, + // Provide path to your CA file and change 'ssl_verify_peer' to true to enable peer validation + // 'ssl_cafile' => '... path to your Certificate Authority file ...', + 'ssl_verify_peer' => false + ); + $response = $request->send(); + if (200 != $response->getStatus()) { + throw new Exception("List download URL returned status: " . + $response->getStatus() . ' ' . $response->getReasonPhrase()); + } + $list = $response->getBody(); + if (false === strpos($list, '// ===BEGIN ICANN DOMAINS===')) { + throw new Exception("List download URL does not contain expected phrase"); + } + if (!($fp = @fopen(OUTPUT_FILE, 'wb'))) { + throw new Exception("Unable to open " . OUTPUT_FILE); + } + +} catch (Exception $e) { + die($e->getMessage()); +} + +$tldTree = ; +$license = true; + +fwrite($fp, "<?php\n"); + +foreach (array_filter(array_map('trim', explode("\n", $list))) as $line) { + if ('//' != substr($line, 0, 2)) { + buildSubdomain($tldTree, explode('.', $line)); + + } elseif ($license) { + if (0 === strpos($line, "// ===BEGIN ICANN DOMAINS===")) { + fwrite($fp, "\n"); + $license = false; + } else { + fwrite($fp, $line . "\n"); + } + } +} + +writeNode($fp, $tldTree); +fwrite($fp, ";\n?>"); +fclose($fp); +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/data/public-suffix-list.php
Added
@@ -0,0 +1,10957 @@ +<?php +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at https://mozilla.org/MPL/2.0/. +// Please pull this list from, and only from https://publicsuffix.org/list/public_suffix_list.dat, +// rather than any other VCS sites. Pulling from any other URL is not guaranteed to be supported. +// Instructions on pulling and using this list can be found at https://publicsuffix.org/list/. + +return + 'ac' => + 'com' => true, + 'edu' => true, + 'gov' => true, + 'net' => true, + 'mil' => true, + 'org' => true, + 'drr' => true + , + 'ad' => + 'nom' => true + , + 'ae' => + 'co' => true, + 'net' => true, + 'org' => true, + 'sch' => true, + 'ac' => true, + 'gov' => true, + 'mil' => true, + 'blogspot' => true + , + 'aero' => + 'accident-investigation' => true, + 'accident-prevention' => true, + 'aerobatic' => true, + 'aeroclub' => true, + 'aerodrome' => true, + 'agents' => true, + 'aircraft' => true, + 'airline' => true, + 'airport' => true, + 'air-surveillance' => true, + 'airtraffic' => true, + 'air-traffic-control' => true, + 'ambulance' => true, + 'amusement' => true, + 'association' => true, + 'author' => true, + 'ballooning' => true, + 'broker' => true, + 'caa' => true, + 'cargo' => true, + 'catering' => true, + 'certification' => true, + 'championship' => true, + 'charter' => true, + 'civilaviation' => true, + 'club' => true, + 'conference' => true, + 'consultant' => true, + 'consulting' => true, + 'control' => true, + 'council' => true, + 'crew' => true, + 'design' => true, + 'dgca' => true, + 'educator' => true, + 'emergency' => true, + 'engine' => true, + 'engineer' => true, + 'entertainment' => true, + 'equipment' => true, + 'exchange' => true, + 'express' => true, + 'federation' => true, + 'flight' => true, + 'fuel' => true, + 'gliding' => true, + 'government' => true, + 'groundhandling' => true, + 'group' => true, + 'hanggliding' => true, + 'homebuilt' => true, + 'insurance' => true, + 'journal' => true, + 'journalist' => true, + 'leasing' => true, + 'logistics' => true, + 'magazine' => true, + 'maintenance' => true, + 'media' => true, + 'microlight' => true, + 'modelling' => true, + 'navigation' => true, + 'parachuting' => true, + 'paragliding' => true, + 'passenger-association' => true, + 'pilot' => true, + 'press' => true, + 'production' => true, + 'recreation' => true, + 'repbody' => true, + 'res' => true, + 'research' => true, + 'rotorcraft' => true, + 'safety' => true, + 'scientist' => true, + 'services' => true, + 'show' => true, + 'skydiving' => true, + 'software' => true, + 'student' => true, + 'trader' => true, + 'trading' => true, + 'trainer' => true, + 'union' => true, + 'workinggroup' => true, + 'works' => true + , + 'af' => + 'gov' => true, + 'com' => true, + 'org' => true, + 'net' => true, + 'edu' => true + , + 'ag' => + 'com' => true, + 'org' => true, + 'net' => true, + 'co' => true, + 'nom' => true + , + 'ai' => + 'off' => true, + 'com' => true, + 'net' => true, + 'org' => true, + 'uwu' => true + , + 'al' => + 'com' => true, + 'edu' => true, + 'gov' => true, + 'mil' => true, + 'net' => true, + 'org' => true, + 'blogspot' => true + , + 'am' => + 'co' => true, + 'com' => true, + 'commune' => true, + 'net' => true, + 'org' => true, + 'radio' => true, + 'blogspot' => true, + 'neko' => true, + 'nyaa' => true + , + 'ao' => + 'ed' => true, + 'gv' => true, + 'og' => true, + 'co' => true, + 'pb' => true, + 'it' => true + , + 'aq' => true, + 'ar' => + 'bet' => true, + 'com' => + 'blogspot' => true + , + 'coop' => true, + 'edu' => true, + 'gob' => true, + 'gov' => true, + 'int' => true, + 'mil' => true, + 'musica' => true, + 'mutual' => true, + 'net' => true, + 'org' => true, + 'senasa' => true, + 'tur' => true + , + 'arpa' => + 'e164' => true, + 'in-addr' => true, + 'ip6' => true, + 'iris' => true, + 'uri' => true, + 'urn' => true + , + 'as' => + 'gov' => true + , + 'asia' =>
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/docs/LICENSE
Added
@@ -0,0 +1,31 @@ +HTTP_Request2 + +Copyright (c) 2008-2023, 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.
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/docs/examples/upload-rapidshare.php
Added
@@ -0,0 +1,58 @@ +<?php +/** + * Usage example for HTTP_Request2 package: uploading a file to rapidshare.com + * + * Inspired by Perl usage example: http://images.rapidshare.com/software/rsapi.pl + * Rapidshare API description: http://rapidshare.com/dev.html + */ + +require_once 'HTTP/Request2.php'; + +// You'll probably want to change this +$filename = '/etc/passwd'; + +try { + // First step: get an available upload server + $request = new HTTP_Request2( + 'http://rapidshare.com/cgi-bin/rsapi.cgi?sub=nextuploadserver_v1' + ); + $server = $request->send()->getBody(); + if (!preg_match('/^(\\d+)$/', $server)) { + throw new Exception("Invalid upload server: {$server}"); + } + + // Calculate file hash, we'll use it later to check upload + if (false === ($hash = @md5_file($filename))) { + throw new Exception("Cannot calculate MD5 hash of '{$filename}'"); + } + + // Second step: upload a file to the available server + $uploader = new HTTP_Request2( + "http://rs{$server}l3.rapidshare.com/cgi-bin/upload.cgi", + HTTP_Request2::METHOD_POST + ); + // Adding the file + $uploader->addUpload('filecontent', $filename); + // This will tell server to return program-friendly output + $uploader->addPostParameter('rsapi_v1', '1'); + + $response = $uploader->send()->getBody(); + if (!preg_match_all('/^(File^=+)=(.+)$/m', $response, $m, PREG_SET_ORDER)) { + throw new Exception("Invalid response: {$response}"); + } + $rspAry = ; + foreach ($m as $item) { + $rspAry$item1 = $item2; + } + // Check that uploaded file has the same hash + if (empty($rspAry'File1.4')) { + throw new Exception("MD5 hash data not found in response"); + } elseif ($hash != strtolower($rspAry'File1.4')) { + throw new Exception("Upload failed, local MD5 is {$hash}, uploaded MD5 is {$rspAry'File1.4'}"); + } + echo "Upload succeeded\nDownload link: {$rspAry'File1.1'}\nDelete link: {$rspAry'File1.2'}\n"; + +} catch (Exception $e) { + echo "Error: " . $e->getMessage(); +} +?>
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/MockObserver.php
Added
@@ -0,0 +1,37 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** + * Mock observer + */ +class HTTP_Request2_MockObserver implements SplObserver +{ + public $calls = 0; + + public $event; + + #ReturnTypeWillChange + public function update (SplSubject $subject) + { + $this->calls++; + $this->event = $subject->getLastEvent(); + } +} +?>
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/NetworkConfig.php.dist
Added
@@ -0,0 +1,58 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** + * This file contains configuration needed for running HTTP_Request2 tests + * that interact with the network. Do not edit this file, copy it to + * NetworkConfig.php and edit the copy instead. + */ + +/** + * Base URL for HTTP_Request2 Adapters tests + * + * To enable the tests that actually perform network interaction, you should + * copy the contents of _network directory to a directory under your web + * server's document root or create a symbolic link to _network directory + * there. Set this constant to point to the URL of that directory. + */ +define('HTTP_REQUEST2_TESTS_BASE_URL', null); + +/** + * URL that is protected by server digest authentication + * + * This is needed for testing of 100 Continue handling, we can't implement + * digest in PHP since it will kick in a bit later + */ +define('HTTP_REQUEST2_TESTS_DIGEST_URL', null); + +/**#@+ + * Proxy setup for Socket Adapter tests + * + * Set these constants to run additional tests for Socket Adapter using a HTTP + * proxy. If proxy host is not set then the tests will not be run. + */ +define('HTTP_REQUEST2_TESTS_PROXY_HOST', null); +define('HTTP_REQUEST2_TESTS_PROXY_PORT', 8080); +define('HTTP_REQUEST2_TESTS_PROXY_USER', ''); +define('HTTP_REQUEST2_TESTS_PROXY_PASSWORD', ''); +define('HTTP_REQUEST2_TESTS_PROXY_AUTH_SCHEME', 'basic'); +define('HTTP_REQUEST2_TESTS_PROXY_TYPE', 'http'); +/**#@-*/ +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/ObserverTest.php
Added
@@ -0,0 +1,78 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** Sets up includes */ +require_once __DIR__ . '/TestHelper.php'; + +require_once __DIR__ . '/MockObserver.php'; + +use Yoast\PHPUnitPolyfills\TestCases\TestCase; + +/** + * Unit test for subject-observer pattern implementation in HTTP_Request2 + */ +class HTTP_Request2_ObserverTest extends TestCase +{ + public function testSetLastEvent() + { + $request = new HTTP_Request2(); + $observer = new HTTP_Request2_MockObserver(); + $request->attach($observer); + + $request->setLastEvent('foo', 'bar'); + $this->assertEquals(1, $observer->calls); + $this->assertEquals('name' => 'foo', 'data' => 'bar', $observer->event); + + $request->setLastEvent('baz'); + $this->assertEquals(2, $observer->calls); + $this->assertEquals('name' => 'baz', 'data' => null, $observer->event); + } + + public function testAttachOnlyOnce() + { + $request = new HTTP_Request2(); + $observer = new HTTP_Request2_MockObserver(); + $observer2 = new HTTP_Request2_MockObserver(); + $request->attach($observer); + $request->attach($observer2); + $request->attach($observer); + + $request->setLastEvent('event', 'data'); + $this->assertEquals(1, $observer->calls); + $this->assertEquals(1, $observer2->calls); + } + + public function testDetach() + { + $request = new HTTP_Request2(); + $observer = new HTTP_Request2_MockObserver(); + $observer2 = new HTTP_Request2_MockObserver(); + + $request->attach($observer); + $request->detach($observer2); // should not be a error + $request->setLastEvent('first'); + + $request->detach($observer); + $request->setLastEvent('second'); + $this->assertEquals(1, $observer->calls); + $this->assertEquals('name' => 'first', 'data' => null, $observer->event); + } +} +?>
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/Adapter/CommonNetworkTest.php
Added
@@ -0,0 +1,450 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** Sets up includes */ +require_once dirname(dirname(__DIR__)) . '/TestHelper.php'; + +require_once __DIR__ . '/SlowpokeBody.php'; +require_once __DIR__ . '/HeaderObserver.php'; +require_once __DIR__ . '/EventSequenceObserver.php'; + +use Yoast\PHPUnitPolyfills\TestCases\TestCase; + +/** + * Tests for HTTP_Request2 package that require a working webserver + * + * The class contains some common tests that should be run for all Adapters, + * it is extended by their unit tests. + * + * You need to properly set up this test suite, refer to NetworkConfig.php.dist + */ +abstract class HTTP_Request2_Adapter_CommonNetworkTest extends TestCase +{ + /** + * HTTP Request object + * @var HTTP_Request2 + */ + protected $request; + + /** + * Base URL for remote test files + * @var string + */ + protected $baseUrl; + + /** + * Configuration for HTTP Request object + * @var array + */ + protected $config = ; + + protected function set_up() + { + if (!HTTP_REQUEST2_TESTS_BASE_URL) { + $this->markTestSkipped('Base URL is not configured'); + + } else { + $this->baseUrl = rtrim(HTTP_REQUEST2_TESTS_BASE_URL, '/') . '/'; + $name = strtolower(preg_replace('/^test/i', '', $this->getName())) . '.php'; + + $this->request = new HTTP_Request2( + $this->baseUrl . $name, HTTP_Request2::METHOD_GET, $this->config + ); + } + } + + /** + * Tests possibility to send GET parameters + * + * NB: Currently there are problems with Net_URL2::setQueryVariables(), thus + * array structure is simple: http://pear.php.net/bugs/bug.php?id=18267 + */ + public function testGetParameters() + { + $data = + 'bar' => + 'key' => 'value' + , + 'foo' => 'some value', + 'numbered' => 'first', 'second' + ; + + $this->request->getUrl()->setQueryVariables($data); + $response = $this->request->send(); + $this->assertEquals(serialize($data), $response->getBody()); + } + + public function testPostParameters() + { + $data = + 'bar' => + 'key' => 'some other value' + , + 'baz' => + 'key1' => + 'key2' => 'yet another value' + + , + 'foo' => 'some value', + 'indexed' => 'first', 'second' + ; + $events = + 'sentHeaders', 'sentBodyPart', 'sentBody', 'receivedHeaders', 'receivedBodyPart', 'receivedBody' + ; + $observer = new HTTP_Request2_Adapter_EventSequenceObserver($events); + + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->setHeader('Accept-Encoding', 'identity') + ->addPostParameter($data) + ->attach($observer); + + $response = $this->request->send(); + $this->assertEquals(serialize($data), $response->getBody()); + $this->assertEquals($events, $observer->sequence); + } + + public function testUploads() + { + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->addUpload('foo', dirname(dirname(__DIR__)) . '/_files/empty.gif', 'picture.gif', 'image/gif') + ->addUpload('bar', + dirname(dirname(__DIR__)) . '/_files/empty.gif', null, 'image/gif', + dirname(dirname(__DIR__)) . '/_files/plaintext.txt', 'secret.txt', 'text/x-whatever' + ); + + $response = $this->request->send(); + $this->assertStringContainsString("foo picture.gif image/gif 43", $response->getBody()); + $this->assertStringContainsString("bar0 empty.gif image/gif 43", $response->getBody()); + $this->assertStringContainsString("bar1 secret.txt text/x-whatever 15", $response->getBody()); + } + + public function testRawPostData() + { + $data = 'Nothing to see here, move along'; + + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->setBody($data); + $response = $this->request->send(); + $this->assertEquals($data, $response->getBody()); + } + + public function testCookies() + { + $cookies = + 'CUSTOMER' => 'WILE_E_COYOTE', + 'PART_NUMBER' => 'ROCKET_LAUNCHER_0001' + ; + + foreach ($cookies as $k => $v) { + $this->request->addCookie($k, $v); + } + $response = $this->request->send(); + $this->assertEquals(serialize($cookies), $response->getBody()); + } + + public function testTimeout() + { + $this->request->setConfig('timeout', 2); + try { + $this->request->send(); + $this->fail('Expected HTTP_Request2_Exception was not thrown'); + } catch (HTTP_Request2_MessageException $e) { + $this->assertEquals(HTTP_Request2_Exception::TIMEOUT, $e->getCode()); + } + } + + public function testTimeoutInRequest() + { + $this->request->setConfig('timeout', 2) + ->setUrl($this->baseUrl . 'postparameters.php') + ->setBody(new HTTP_Request2_Adapter_SlowpokeBody('foo' => 'some value', )); + try { + $this->request->send(); + $this->fail('Expected HTTP_Request2_MessageException was not thrown'); + } catch (HTTP_Request2_MessageException $e) { + $this->assertEquals(HTTP_Request2_Exception::TIMEOUT, $e->getCode()); + } + } + + public function testBasicAuth() + { + $this->request->getUrl()->setQueryVariables( + 'user' => 'luser', + 'pass' => 'qwerty' + ); + $wrong = clone $this->request; + + $this->request->setAuth('luser', 'qwerty'); + $response = $this->request->send(); + $this->assertEquals(200, $response->getStatus()); + + $wrong->setAuth('luser', 'password'); + $response = $wrong->send();
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/Adapter/CurlTest.php
Added
@@ -0,0 +1,180 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** Tests for HTTP_Request2 package that require a working webserver */ +require_once __DIR__ . '/CommonNetworkTest.php'; + +require_once __DIR__ . '/UploadSizeObserver.php'; + +/** + * Unit test for Curl Adapter of HTTP_Request2 + */ +class HTTP_Request2_Adapter_CurlTest extends HTTP_Request2_Adapter_CommonNetworkTest +{ + /** + * Configuration for HTTP Request object + * @var array + */ + protected $config = + 'adapter' => \HTTP_Request2_Adapter_Curl::class + ; + + protected function set_up() + { + parent::set_up(); + if (!extension_loaded('curl')) { + $this->markTestSkipped("Curl extension should be enabled to run Curl tests"); + } + } + + /** + * Checks whether redirect support in cURL is disabled by safe_mode or open_basedir + * @return bool + */ + protected function isRedirectSupportDisabled() + { + return ini_get('safe_mode') || ini_get('open_basedir'); + } + + public function testRedirectsDefault() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testRedirectsDefault(); + } + } + + public function testRedirectsStrict() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testRedirectsStrict(); + } + } + + public function testRedirectsLimit() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testRedirectsLimit(); + } + } + + public function testRedirectsRelative() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testRedirectsRelative(); + } + } + + public function testRedirectsNonHTTP() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testRedirectsNonHTTP(); + } + } + + public function testCookieJarAndRedirect() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + } else { + parent::testCookieJarAndRedirect(); + } + } + + public function testBug17450() + { + if (!$this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Neither safe_mode nor open_basedir is enabled'); + } + + $this->request->setUrl($this->baseUrl . 'redirects.php') + ->setConfig('follow_redirects' => true); + + try { + $this->request->send(); + $this->fail('Expected HTTP_Request2_Exception was not thrown'); + + } catch (HTTP_Request2_LogicException $e) { + $this->assertEquals(HTTP_Request2_Exception::MISCONFIGURATION, $e->getCode()); + } + } + + public function testBug20440() + { + $this->request->setUrl($this->baseUrl . 'rawpostdata.php') + ->setMethod(HTTP_Request2::METHOD_PUT) + ->setHeader('Expect', '') + ->setBody('This is a test'); + + $noredirects = clone $this->request; + $noredirects->setConfig('follow_redirects', false) + ->attach($observer = new HTTP_Request2_Adapter_UploadSizeObserver()); + $noredirects->send(); + // Curl sends body with Transfer-encoding: chunked, so size can be larger + $this->assertGreaterThanOrEqual(14, $observer->size); + + $redirects = clone $this->request; + $redirects->setConfig('follow_redirects', true) + ->attach($observer = new HTTP_Request2_Adapter_UploadSizeObserver()); + $redirects->send(); + $this->assertGreaterThanOrEqual(14, $observer->size); + } + + /** + * An URL performing a redirect was used for storing cookies in a jar rather than target URL + * + * @link http://pear.php.net/bugs/bug.php?id=20561 + */ + public function testBug20561() + { + if ($this->isRedirectSupportDisabled()) { + $this->markTestSkipped('Redirect support in cURL is disabled by safe_mode or open_basedir setting'); + + } else { + $this->request->setUrl($this->baseUrl . 'redirects.php?special=youtube') + ->setConfig( + 'follow_redirects' => true, + 'ssl_verify_peer' => false + ) + ->setCookieJar(true); + + $this->request->send(); + $this->assertGreaterThan(0, count($this->request->getCookieJar()->getAll())); + } + } + + public function testIncompleteBody() + { + if (version_compare(phpversion(), '7.4', '>=')) { + $this::expectException(\HTTP_Request2_Exception::class); + } + parent::testIncompleteBody(); + } +} +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/Adapter/EventSequenceObserver.php
Added
@@ -0,0 +1,50 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** + * Saves observed event names + */ +class HTTP_Request2_Adapter_EventSequenceObserver implements SplObserver +{ + private $_watched = ; + + public $sequence = ; + + public function __construct(array $watchedEvents = ) + { + if (!empty($watchedEvents)) { + $this->_watched = $watchedEvents; + } + } + + #ReturnTypeWillChange + public function update(SplSubject $subject) + { + /* @var $subject HTTP_Request2 */ + $event = $subject->getLastEvent(); + + if ($event'name' !== end($this->sequence) + && (empty($this->_watched) || in_array($event'name', $this->_watched, true)) + ) { + $this->sequence = $event'name'; + } + } +} +?>
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/Adapter/HeaderObserver.php
Added
@@ -0,0 +1,39 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** + * Observer that saves request headers + */ +class HTTP_Request2_Adapter_HeaderObserver implements SplObserver +{ + public $headers; + + #ReturnTypeWillChange + public function update(SplSubject $subject) + { + /* @var $subject HTTP_Request2 */ + $event = $subject->getLastEvent(); + + if ('sentHeaders' == $event'name') { + $this->headers = $event'data'; + } + } +} +?>
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/Adapter/MockTest.php
Added
@@ -0,0 +1,149 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** Sets up includes */ +require_once dirname(dirname(__DIR__)) . '/TestHelper.php'; + +use Yoast\PHPUnitPolyfills\TestCases\TestCase; + +/** + * Unit test for HTTP_Request2_Response class + */ +class HTTP_Request2_Adapter_MockTest extends TestCase +{ + public function testDefaultResponse() + { + $req = new HTTP_Request2('http://www.example.com/', HTTP_Request2::METHOD_GET, + 'adapter' => 'mock'); + $response = $req->send(); + $this->assertEquals(400, $response->getStatus()); + $this->assertEquals(0, count($response->getHeader())); + $this->assertEquals('', $response->getBody()); + } + + public function testResponseFromString() + { + $mock = new HTTP_Request2_Adapter_Mock(); + $mock->addResponse( + "HTTP/1.1 200 OK\r\n" . + "Content-Type: text/plain; charset=iso-8859-1\r\n" . + "\r\n" . + "This is a string" + ); + $req = new HTTP_Request2('http://www.example.com/'); + $req->setAdapter($mock); + + $response = $req->send(); + $this->assertEquals(200, $response->getStatus()); + $this->assertEquals(1, count($response->getHeader())); + $this->assertEquals('This is a string', $response->getBody()); + } + + public function testResponseFromFile() + { + $mock = new HTTP_Request2_Adapter_Mock(); + $mock->addResponse(fopen(dirname(dirname(__DIR__)) . + '/_files/response_headers', 'rb')); + + $req = new HTTP_Request2('http://www.example.com/'); + $req->setAdapter($mock); + + $response = $req->send(); + $this->assertEquals(200, $response->getStatus()); + $this->assertEquals(7, count($response->getHeader())); + $this->assertEquals('Nothing to see here, move along.', $response->getBody()); + } + + public function testResponsesQueue() + { + $mock = new HTTP_Request2_Adapter_Mock(); + $mock->addResponse( + "HTTP/1.1 301 Over there\r\n" . + "Location: http://www.example.com/newpage.html\r\n" . + "\r\n" . + "The document is over there" + ); + $mock->addResponse( + "HTTP/1.1 200 OK\r\n" . + "Content-Type: text/plain; charset=iso-8859-1\r\n" . + "\r\n" . + "This is a string" + ); + + $req = new HTTP_Request2('http://www.example.com/'); + $req->setAdapter($mock); + $this->assertEquals(301, $req->send()->getStatus()); + $this->assertEquals(200, $req->send()->getStatus()); + $this->assertEquals(400, $req->send()->getStatus()); + } + + /** + * Returning URL-specific responses + * @link http://pear.php.net/bugs/bug.php?id=19276 + */ + public function testRequest19276() + { + $mock = new HTTP_Request2_Adapter_Mock(); + $mock->addResponse( + "HTTP/1.1 200 OK\r\n" . + "Content-Type: text/plain; charset=iso-8859-1\r\n" . + "\r\n" . + "This is a response from example.org", + 'http://example.org/' + ); + $mock->addResponse( + "HTTP/1.1 200 OK\r\n" . + "Content-Type: text/plain; charset=iso-8859-1\r\n" . + "\r\n" . + "This is a response from example.com", + 'http://example.com/' + ); + + $req1 = new HTTP_Request2('http://localhost/'); + $req1->setAdapter($mock); + $this->assertEquals(400, $req1->send()->getStatus()); + + $req2 = new HTTP_Request2('http://example.com/'); + $req2->setAdapter($mock); + $this->assertStringContainsString('example.com', $req2->send()->getBody()); + + $req3 = new HTTP_Request2('http://example.org'); + $req3->setAdapter($mock); + $this->assertStringContainsString('example.org', $req3->send()->getBody()); + } + + public function testResponseException() + { + $mock = new HTTP_Request2_Adapter_Mock(); + $mock->addResponse( + new HTTP_Request2_Exception('Shit happens') + ); + $req = new HTTP_Request2('http://www.example.com/'); + $req->setAdapter($mock); + try { + $req->send(); + } catch (Exception $e) { + $this->assertEquals('Shit happens', $e->getMessage()); + return; + } + $this->fail('Expected HTTP_Request2_Exception was not thrown'); + } +} +?>
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/Adapter/SlowpokeBody.php
Added
@@ -0,0 +1,43 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** + * Makes a 3 second delay before sending the request body + */ +class HTTP_Request2_Adapter_SlowpokeBody extends HTTP_Request2_MultipartBody +{ + protected $doSleep; + + public function rewind() + { + $this->doSleep = true; + parent::rewind(); + } + + public function read($length) + { + if ($this->doSleep) { + sleep(3); + $this->doSleep = false; + } + return parent::read($length); + } +} +?>
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/Adapter/SocketProxyTest.php
Added
@@ -0,0 +1,56 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** Tests for HTTP_Request2 package that require a working webserver */ +require_once __DIR__ . '/CommonNetworkTest.php'; + +/** + * Unit test for Socket Adapter of HTTP_Request2 working through proxy + */ +class HTTP_Request2_Adapter_SocketProxyTest extends HTTP_Request2_Adapter_CommonNetworkTest +{ + /** + * Configuration for HTTP Request object + * @var array + */ + protected $config = + 'adapter' => \HTTP_Request2_Adapter_Socket::class + ; + + protected function set_up() + { + parent::set_up(); + + if (!HTTP_REQUEST2_TESTS_PROXY_HOST) { + $this->markTestSkipped('Proxy is not configured'); + + } else { + $this->config += + 'proxy_host' => HTTP_REQUEST2_TESTS_PROXY_HOST, + 'proxy_port' => HTTP_REQUEST2_TESTS_PROXY_PORT, + 'proxy_user' => HTTP_REQUEST2_TESTS_PROXY_USER, + 'proxy_password' => HTTP_REQUEST2_TESTS_PROXY_PASSWORD, + 'proxy_auth_scheme' => HTTP_REQUEST2_TESTS_PROXY_AUTH_SCHEME, + 'proxy_type' => HTTP_REQUEST2_TESTS_PROXY_TYPE + ; + } + } +} +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/Adapter/SocketTest.php
Added
@@ -0,0 +1,214 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** Tests for HTTP_Request2 package that require a working webserver */ +require_once __DIR__ . '/CommonNetworkTest.php'; + +/** + * Unit test for Socket Adapter of HTTP_Request2 + */ +class HTTP_Request2_Adapter_SocketTest extends HTTP_Request2_Adapter_CommonNetworkTest +{ + /** + * Configuration for HTTP Request object + * @var array + */ + protected $config = + 'adapter' => \HTTP_Request2_Adapter_Socket::class + ; + + /** + * @doesNotPerformAssertions + */ + public function testBug17826() + { + $adapter = new HTTP_Request2_Adapter_Socket(); + + $request1 = new HTTP_Request2($this->baseUrl . 'redirects.php?redirects=2'); + $request1->setConfig('follow_redirects' => true, 'max_redirects' => 3) + ->setAdapter($adapter) + ->send(); + + $request2 = new HTTP_Request2($this->baseUrl . 'redirects.php?redirects=2'); + $request2->setConfig('follow_redirects' => true, 'max_redirects' => 3) + ->setAdapter($adapter) + ->send(); + } + + + /** + * Infinite loop with stream wrapper passed as upload + * + * Dunno how the original reporter managed to pass a file pointer + * that doesn't support fstat() to MultipartBody, maybe he didn't use + * addUpload(). So we don't use it, either. + * + * @link http://pear.php.net/bugs/bug.php?id=19934 + */ + public function testBug19934() + { + if (!in_array('http', stream_get_wrappers())) { + $this->markTestSkipped("This test requires an HTTP fopen wrapper enabled"); + } + + $fp = fopen($this->baseUrl . '/bug19934.php', 'rb'); + $body = new HTTP_Request2_MultipartBody( + , + + 'upload' => + 'fp' => $fp, + 'filename' => 'foo.txt', + 'type' => 'text/plain', + 'size' => 20000 + + + ); + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->setUrl($this->baseUrl . 'uploads.php') + ->setBody($body); + + set_error_handler($this, 'rewindWarningsHandler'); + $response = $this->request->send(); + restore_error_handler(); + + $this->assertStringContainsString("upload foo.txt text/plain 20000", $response->getBody()); + } + + public function rewindWarningsHandler($errno, $errstr) + { + if (($errno & E_WARNING) && false !== strpos($errstr, 'rewind')) { + return true; + } + return false; + } + + /** + * Do not send request body twice to URLs protected by digest auth + * + * @link http://pear.php.net/bugs/bug.php?id=19233 + */ + public function test100ContinueHandling() + { + if (!HTTP_REQUEST2_TESTS_DIGEST_URL) { + $this->markTestSkipped('This test requires an URL protected by server digest auth'); + } + + $fp = fopen(dirname(dirname(__DIR__)) . '/_files/bug_15305', 'rb'); + $body = $this->getMockBuilder(\HTTP_Request2_MultipartBody::class) + ->setMethods('read') + ->setConstructorArgs( + , + + 'upload' => + 'fp' => $fp, + 'filename' => 'bug_15305', + 'type' => 'application/octet-stream', + 'size' => 16338 + + + ) + ->getMock(); + $body->expects($this->never())->method('read'); + + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->setUrl(HTTP_REQUEST2_TESTS_DIGEST_URL) + ->setBody($body); + + $this->assertEquals(401, $this->request->send()->getStatus()); + } + + public function test100ContinueTimeoutBug() + { + $fp = fopen(dirname(dirname(__DIR__)) . '/_files/bug_15305', 'rb'); + $body = new HTTP_Request2_MultipartBody( + , + + 'upload' => + 'fp' => $fp, + 'filename' => 'bug_15305', + 'type' => 'application/octet-stream', + 'size' => 16338 + + + ); + + $this->request->setMethod(HTTP_Request2::METHOD_POST) + ->setUrl($this->baseUrl . 'uploads.php?slowpoke') + ->setBody($body); + + $response = $this->request->send(); + $this->assertStringContainsString('upload bug_15305 application/octet-stream 16338', $response->getBody()); + } + + /** + * Socket adapter should not throw an exception (invalid chunk length '') + * if a buggy server doesn't send last zero-length chunk when using chunked encoding + * + * @link http://pear.php.net/bugs/bug.php?id=20228 + */ + public function testBug20228() + { + $events = 'receivedBodyPart', 'warning', 'receivedBody'; + $this->request->setHeader('Accept-Encoding', 'identity') + ->attach($observer = new HTTP_Request2_Adapter_EventSequenceObserver($events)); + $response = $this->request->send(); + + if (false === strpos((string)$response->getHeader('Server'), 'Apache')) { + $this->markTestSkipped("This test will likely fail on non-Apache web server"); + } + + $this->assertEquals('This is a test', $response->getBody()); + $this->assertEquals($events, $observer->sequence); + } + + public function testHowsMySSL() + { + if (!in_array('ssl', stream_get_transports())) { + $this->markTestSkipped("This test requires SSL support"); + } + + $this->request->setUrl('https://www.howsmyssl.com/a/check') + ->setConfig('ssl_verify_peer', false); + + if (null === ($responseData = json_decode($this->request->send()->getBody(), true))) { + $this->fail('Cannot decode JSON from howsmyssl.com response'); + } + + $this->assertEmpty($responseData'insecure_cipher_suites'); + + $this->assertEquals('Probably Okay', $responseData'rating'); + } + + public function testDefaultSocketTimeout()
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/Adapter/UploadSizeObserver.php
Added
@@ -0,0 +1,40 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** + * Stores the length of request body + */ +class HTTP_Request2_Adapter_UploadSizeObserver implements SplObserver +{ + public $size; + + #ReturnTypeWillChange + public function update(SplSubject $subject) + { + /* @var $subject HTTP_Request2 */ + $event = $subject->getLastEvent(); + + if ('sentBody' == $event'name') { + $this->size = $event'data'; + } + } + +} +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/CookieJarTest.php
Added
@@ -0,0 +1,401 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** Sets up includes */ +require_once dirname(__DIR__) . '/TestHelper.php'; + +use Yoast\PHPUnitPolyfills\TestCases\TestCase; + +/** + * Unit test for HTTP_Request2_CookieJar class + */ +class HTTP_Request2_CookieJarTest extends TestCase +{ + /** + * Cookie jar instance being tested + * @var HTTP_Request2_CookieJar + */ + protected $jar; + + protected function set_up() + { + $this->jar = new HTTP_Request2_CookieJar(); + } + + /** + * Test that we can't store junk "cookies" in jar + * + * @dataProvider invalidCookieProvider + */ + public function testStoreInvalid($cookie) + { + $this->expectException(\HTTP_Request2_LogicException::class); + $this->jar->store($cookie); + } + + /** + * Per feature requests, allow to ignore invalid cookies rather than throw exceptions + * + * @link http://pear.php.net/bugs/bug.php?id=19937 + * @link http://pear.php.net/bugs/bug.php?id=20401 + * @dataProvider invalidCookieProvider + */ + public function testCanIgnoreInvalidCookies($cookie) + { + $this->jar->ignoreInvalidCookies(true); + $this->assertFalse($this->jar->store($cookie)); + } + + /** + * Ignore setting a cookie from "parallel" subdomain when relevant option is on + * + * @link http://pear.php.net/bugs/bug.php?id=20401 + */ + public function testRequest20401() + { + $this->jar->ignoreInvalidCookies(true); + $response = HTTP_Request2_Adapter_Mock::createResponseFromFile( + fopen(dirname(__DIR__) . '/_files/response_cookies', 'rb') + ); + $setter = new Net_URL2('http://pecl.php.net/'); + + $this->assertFalse($this->jar->addCookiesFromResponse($response, $setter)); + $this->assertCount(3, $this->jar->getAll()); + } + + + /** + * + * @dataProvider noPSLDomainsProvider + */ + public function testDomainMatchNoPSL($requestHost, $cookieDomain, $expected) + { + $this->jar->usePublicSuffixList(false); + $this->assertEquals($expected, $this->jar->domainMatch($requestHost, $cookieDomain)); + } + + /** + * + * @dataProvider PSLDomainsProvider + */ + public function testDomainMatchPSL($requestHost, $cookieDomain, $expected) + { + $this->jar->usePublicSuffixList(true); + $this->assertEquals($expected, $this->jar->domainMatch($requestHost, $cookieDomain)); + } + + public function testConvertExpiresToISO8601() + { + $dt = new DateTime(); + $dt->setTimezone(new DateTimeZone('UTC')); + $dt->modify('+1 day'); + + $this->jar->store( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => '/', + 'expires' => $dt->format(DateTime::COOKIE), + 'secure' => false + ); + $cookies = $this->jar->getAll(); + $this->assertEquals($cookies0'expires', $dt->format(DateTime::ISO8601)); + } + + public function testProblem2038() + { + $this->jar->store( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => '/', + 'expires' => 'Sun, 01 Jan 2040 03:04:05 GMT', + 'secure' => false + ); + $cookies = $this->jar->getAll(); + $this->assertEquals( + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => '/', + 'expires' => '2040-01-01T03:04:05+0000', + 'secure' => false + , $cookies); + } + + public function testStoreExpired() + { + $base = + 'name' => 'foo', + 'value' => 'bar', + 'domain' => '.example.com', + 'path' => '/', + 'secure' => false + ; + + $dt = new DateTime(); + $dt->setTimezone(new DateTimeZone('UTC')); + $dt->modify('-1 day'); + $yesterday = $dt->format(DateTime::COOKIE); + + $dt->modify('+2 days'); + $tomorrow = $dt->format(DateTime::COOKIE); + + $this->jar->store($base + 'expires' => $yesterday); + $this->assertEquals(0, count($this->jar->getAll())); + + $this->jar->store($base + 'expires' => $tomorrow); + $this->assertEquals(1, count($this->jar->getAll())); + $this->jar->store($base + 'expires' => $yesterday); + $this->assertEquals(0, count($this->jar->getAll())); + } + + /** + * + * @dataProvider cookieAndSetterProvider + */ + public function testGetDomainAndPathFromSetter($cookie, $setter, $expected) + { + $this->jar->store($cookie, $setter); + $expected = array_merge($cookie, $expected); + $cookies = $this->jar->getAll(); + $this->assertEquals($expected, $cookies0); + } + + /** + * + * @dataProvider cookieMatchProvider + */ + public function testGetMatchingCookies($url, $expectedCount) + { + $cookies = + 'domain' => '.example.com', 'path' => '/', 'secure' => false, + 'domain' => '.example.com', 'path' => '/', 'secure' => true, + 'domain' => '.example.com', 'path' => '/path', 'secure' => false, + 'domain' => '.example.com', 'path' => '/other', 'secure' => false, + 'domain' => 'example.com', 'path' => '/', 'secure' => false, + 'domain' => 'www.example.com', 'path' => '/', 'secure' => false, + 'domain' => 'specific.example.com', 'path' => '/path', 'secure' => false, + 'domain' => 'nowww.example.com', 'path' => '/', 'secure' => false, + ; + + for ($i = 0; $i < count($cookies); $i++) {
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/MultipartBodyTest.php
Added
@@ -0,0 +1,96 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** Sets up includes */ +require_once dirname(__DIR__) . '/TestHelper.php'; + +use Yoast\PHPUnitPolyfills\TestCases\TestCase; + +/** + * Unit test for HTTP_Request2_MultipartBody class + */ +class HTTP_Request2_MultipartBodyTest extends TestCase +{ + public function testUploadSimple() + { + $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); + $body = $req->addPostParameter('foo', 'I am a parameter') + ->addUpload('upload', dirname(__DIR__) . '/_files/plaintext.txt') + ->getBody(); + + $this->assertTrue($body instanceof HTTP_Request2_MultipartBody); + $asString = $body->__toString(); + $boundary = $body->getBoundary(); + $this->assertEquals($body->getLength(), strlen($asString)); + $this->assertStringContainsString('This is a test.', $asString); + $this->assertStringContainsString('I am a parameter', $asString); + $this->assertMatchesRegularExpression("!--{$boundary}--\r\n$!", $asString); + } + + public function testRequest16863() + { + $this->expectException(\HTTP_Request2_LogicException::class); + $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); + $fp = fopen(dirname(__DIR__) . '/_files/plaintext.txt', 'rb'); + $body = $req->addUpload('upload', $fp) + ->getBody(); + + $asString = $body->__toString(); + $this->assertStringContainsString('name="upload"; filename="anonymous.blob"', $asString); + $this->assertStringContainsString('This is a test.', $asString); + + $req->addUpload('bad_upload', fopen('php://input', 'rb')); + } + + public function testStreaming() + { + $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); + $body = $req->addPostParameter('foo', 'I am a parameter') + ->addUpload('upload', dirname(__DIR__) . '/_files/plaintext.txt') + ->getBody(); + $asString = ''; + while ($part = $body->read(10)) { + $asString .= $part; + } + $this->assertEquals($body->getLength(), strlen($asString)); + $this->assertStringContainsString('This is a test.', $asString); + $this->assertStringContainsString('I am a parameter', $asString); + } + + public function testUploadArray() + { + $req = new HTTP_Request2(null, HTTP_Request2::METHOD_POST); + $body = $req->addUpload('upload', + dirname(__DIR__) . '/_files/plaintext.txt', 'bio.txt', 'text/plain', + fopen(dirname(__DIR__) . '/_files/empty.gif', 'rb'), 'photo.gif', 'image/gif' + ) + ->getBody(); + $asString = $body->__toString(); + $this->assertStringContainsString(file_get_contents(dirname(__DIR__) . '/_files/empty.gif'), $asString); + $this->assertStringContainsString('name="upload0"; filename="bio.txt"', $asString); + $this->assertStringContainsString('name="upload1"; filename="photo.gif"', $asString); + + $body2 = $req->setConfig('use_brackets' => false)->getBody(); + $asString = $body2->__toString(); + $this->assertStringContainsString('name="upload"; filename="bio.txt"', $asString); + $this->assertStringContainsString('name="upload"; filename="photo.gif"', $asString); + } +} +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2/ResponseTest.php
Added
@@ -0,0 +1,150 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** Sets up includes */ +require_once dirname(__DIR__) . '/TestHelper.php'; + +use Yoast\PHPUnitPolyfills\TestCases\TestCase; + +/** + * Unit test for HTTP_Request2_Response class + */ +class HTTP_Request2_ResponseTest extends TestCase +{ + public function testParseStatusLine() + { + $this->expectException(\HTTP_Request2_MessageException::class); + $response = new HTTP_Request2_Response('HTTP/1.1 200 OK'); + $this->assertEquals('1.1', $response->getVersion()); + $this->assertEquals(200, $response->getStatus()); + $this->assertEquals('OK', $response->getReasonPhrase()); + + $response2 = new HTTP_Request2_Response('HTTP/1.2 222 Nishtyak!'); + $this->assertEquals('1.2', $response2->getVersion()); + $this->assertEquals(222, $response2->getStatus()); + $this->assertEquals('Nishtyak!', $response2->getReasonPhrase()); + + $response3 = new HTTP_Request2_Response('HTTP/1.1 200 '); + $this->assertEquals('1.1', $response3->getVersion()); + $this->assertEquals(200, $response3->getStatus()); + $this->assertEquals('OK', $response3->getReasonPhrase()); + + $response4 = new HTTP_Request2_Response("HTTP/1.1 200 \r\n"); + $this->assertEquals('1.1', $response4->getVersion()); + $this->assertEquals(200, $response4->getStatus()); + $this->assertEquals('OK', $response4->getReasonPhrase()); + + // RFC 9112 gives the following definition for reason-phrase: + // > reason-phrase = 1*( HTAB / SP / VCHAR / obs-text ) + // so do not use trim() and consider whitespace-only reason-phrase as present + $response5 = new HTTP_Request2_Response("HTTP/1.1 200 \r\n"); + $this->assertEquals('1.1', $response5->getVersion()); + $this->assertEquals(200, $response5->getStatus()); + $this->assertEquals(' ', $response5->getReasonPhrase()); + + new HTTP_Request2_Response('Invalid status line'); + } + + /** + * https://www.rfc-editor.org/rfc/rfc9112.html#name-status-line + * + * > A server MUST send the space that separates the status-code from + * > the reason-phrase even when the reason-phrase is absent + * > (i.e., the status-line would end with the space). + */ + public function testSpaceIsRequiredAfterStatusCode() + { + $this->expectException(\HTTP_Request2_MessageException::class); + new HTTP_Request2_Response('HTTP/1.1 200'); + } + + public function testParseHeaders() + { + $response = $this->readResponseFromFile('response_headers'); + $this->assertEquals(7, count($response->getHeader())); + $this->assertEquals('PHP/6.2.2', $response->getHeader('X-POWERED-BY')); + $this->assertEquals('text/html; charset=windows-1251', $response->getHeader('cOnTeNt-TyPe')); + $this->assertEquals('accept-charset, user-agent', $response->getHeader('vary')); + } + + public function testParseCookies() + { + $response = $this->readResponseFromFile('response_cookies'); + $cookies = $response->getCookies(); + $this->assertEquals(4, count($cookies)); + $expected = + 'name' => 'foo', 'value' => 'bar', 'expires' => null, + 'domain' => null, 'path' => null, 'secure' => false, + 'name' => 'PHPSESSID', 'value' => '1234567890abcdef1234567890abcdef', + 'expires' => null, 'domain' => null, 'path' => '/', 'secure' => true, + 'name' => 'A', 'value' => 'B=C', 'expires' => null, + 'domain' => null, 'path' => null, 'secure' => false, + 'name' => 'baz', 'value' => '%20a%20value', 'expires' => 'Sun, 03 Jan 2010 03:04:05 GMT', + 'domain' => 'pear.php.net', 'path' => null, 'secure' => false, + ; + foreach ($cookies as $k => $cookie) { + $this->assertEquals($expected$k, $cookie); + } + } + + public function testGzipEncoding() + { + $this->expectException(\HTTP_Request2_MessageException::class); + $response = $this->readResponseFromFile('response_gzip'); + $this->assertEquals('0e964e9273c606c46afbd311b5ad4d77', md5($response->getBody())); + + $response = $this->readResponseFromFile('response_gzip_broken'); + $response->getBody(); + } + + public function testDeflateEncoding() + { + $response = $this->readResponseFromFile('response_deflate'); + $this->assertEquals('0e964e9273c606c46afbd311b5ad4d77', md5($response->getBody())); + } + + public function testBug15305() + { + $response = $this->readResponseFromFile('bug_15305'); + $this->assertEquals('c8c5088fc8a7652afef380f086c010a6', md5($response->getBody())); + } + + public function testBug18169() + { + $response = $this->readResponseFromFile('bug_18169'); + $this->assertEquals('', $response->getBody()); + } + + protected function readResponseFromFile($filename) + { + $fp = fopen(dirname(__DIR__) . '/_files/' . $filename, 'rb'); + $response = new HTTP_Request2_Response(fgets($fp)); + do { + $headerLine = fgets($fp); + $response->parseHeaderLine($headerLine); + } while ('' != trim($headerLine)); + + while (!feof($fp)) { + $response->appendBody(fread($fp, 1024)); + } + return $response; + } +} +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/Request2Test.php
Added
@@ -0,0 +1,361 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** Sets up includes */ +require_once __DIR__ . '/TestHelper.php'; + +use Yoast\PHPUnitPolyfills\TestCases\TestCase; + +/** + * Unit test for HTTP_Request2 class + */ +class HTTP_Request2Test extends TestCase +{ + public function testConstructorSetsDefaults() + { + $url = new Net_URL2('http://www.example.com/foo'); + $req = new HTTP_Request2($url, HTTP_Request2::METHOD_POST, 'connect_timeout' => 666); + + $this->assertSame($url, $req->getUrl()); + $this->assertEquals(HTTP_Request2::METHOD_POST, $req->getMethod()); + $this->assertEquals(666, $req->getConfig('connect_timeout')); + } + + public function testSetUrl() + { + $this->expectException(\HTTP_Request2_LogicException::class); + $urlString = 'http://www.example.com/foo/bar.php'; + $url = new Net_URL2($urlString); + + $req1 = new HTTP_Request2(); + $req1->setUrl($url); + $this->assertSame($url, $req1->getUrl()); + + $req2 = new HTTP_Request2(); + $req2->setUrl($urlString); + $this->assertInstanceOf(\Net_URL2::class, $req2->getUrl()); + $this->assertEquals($urlString, $req2->getUrl()->getUrl()); + + $req3 = new HTTP_Request2(); + $req3->setUrl('This will cause an error'); + } + + public function testConvertUserinfoToAuth() + { + $req = new HTTP_Request2(); + $req->setUrl('http://foo:b%40r@www.example.com/'); + + $this->assertEquals('', (string)$req->getUrl()->getUserinfo()); + $this->assertEquals( + 'user' => 'foo', 'password' => 'b@r', 'scheme' => HTTP_Request2::AUTH_BASIC, + $req->getAuth() + ); + } + + public function testSetMethod() + { + $this->expectException(\HTTP_Request2_LogicException::class); + $req = new HTTP_Request2(); + $req->setMethod(HTTP_Request2::METHOD_PUT); + $this->assertEquals(HTTP_Request2::METHOD_PUT, $req->getMethod()); + + $req->setMethod('Invalid method'); + } + + public function testSetAndGetConfig() + { + $req = new HTTP_Request2(); + $this->assertArrayHasKey('connect_timeout', $req->getConfig()); + + $req->setConfig('connect_timeout' => 123); + $this->assertEquals(123, $req->getConfig('connect_timeout')); + try { + $req->setConfig('foo' => 'unknown parameter'); + $this->fail('Expected HTTP_Request2_LogicException was not thrown'); + } catch (HTTP_Request2_LogicException $e) {} + + try { + $req->getConfig('bar'); + $this->fail('Expected HTTP_Request2_LogicException was not thrown'); + } catch (HTTP_Request2_LogicException $e) {} + } + + public function testSetProxyAsUrl() + { + $req = new HTTP_Request2(); + $req->setConfig('proxy', 'socks5://foo:bar%25baz@localhost:1080/'); + + $this->assertEquals('socks5', $req->getConfig('proxy_type')); + $this->assertEquals('localhost', $req->getConfig('proxy_host')); + $this->assertEquals(1080, $req->getConfig('proxy_port')); + $this->assertEquals('foo', $req->getConfig('proxy_user')); + $this->assertEquals('bar%baz', $req->getConfig('proxy_password')); + } + + public function testHeaders() + { + $this->expectException(\HTTP_Request2_LogicException::class); + $req = new HTTP_Request2(); + $autoHeaders = $req->getHeaders(); + + $req->setHeader('Foo', 'Bar'); + $req->setHeader('Foo-Bar: value'); + $req->setHeader('Another-Header' => 'another value', 'Yet-Another: other_value'); + $this->assertEquals( + 'foo-bar' => 'value', 'another-header' => 'another value', + 'yet-another' => 'other_value', 'foo' => 'Bar' + $autoHeaders, + $req->getHeaders() + ); + + $req->setHeader('FOO-BAR'); + $req->setHeader('aNOTHER-hEADER'); + $this->assertEquals( + 'yet-another' => 'other_value', 'foo' => 'Bar' + $autoHeaders, + $req->getHeaders() + ); + + $req->setHeader('Invalid header', 'value'); + } + + public function testBug15937() + { + $req = new HTTP_Request2(); + $autoHeaders = $req->getHeaders(); + + $req->setHeader('Expect: '); + $req->setHeader('Foo', ''); + $this->assertEquals( + 'expect' => '', 'foo' => '' + $autoHeaders, + $req->getHeaders() + ); + } + + public function testRequest17507() + { + $req = new HTTP_Request2(); + + $req->setHeader('accept-charset', 'iso-8859-1'); + $req->setHeader('accept-charset', 'windows-1251', 'utf-8', false); + + $req->setHeader('accept' => 'text/html'); + $req->setHeader('accept' => 'image/gif', null, false); + + $headers = $req->getHeaders(); + + $this->assertEquals('iso-8859-1, windows-1251, utf-8', $headers'accept-charset'); + $this->assertEquals('text/html, image/gif', $headers'accept'); + } + + public function testCookies() + { + $this->expectException(\HTTP_Request2_LogicException::class); + $req = new HTTP_Request2(); + $req->addCookie('name', 'value'); + $req->addCookie('foo', 'bar'); + $headers = $req->getHeaders(); + $this->assertEquals('name=value; foo=bar', $headers'cookie'); + + $req->addCookie('invalid cookie', 'value'); + } + + public function testPlainBody() + { + $this->expectException(\HTTP_Request2_LogicException::class); + $req = new HTTP_Request2(); + $req->setBody('A string'); + $this->assertEquals('A string', $req->getBody()); + + $req->setBody(__DIR__ . '/_files/plaintext.txt', true); + $headers = $req->getHeaders(); + $this->assertMatchesRegularExpression( + '!^(text/plain|application/octet-stream)!', + $headers'content-type' + ); + $this->assertEquals('This is a test.', fread($req->getBody(), 1024)); + + $req->setBody('missing file', true); + } + + public function testRequest16863() + { + $this->expectException(\HTTP_Request2_LogicException::class); + $req = new HTTP_Request2();
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/TestHelper.php
Added
@@ -0,0 +1,64 @@ +<?php +/** + * Unit tests for HTTP_Request2 package + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +if ('@' . 'package_version@' !== '2.6.0') { + // Installed with PEAR: we should be on the include path, just require_once everything + require_once 'HTTP/Request2.php'; + require_once 'HTTP/Request2/CookieJar.php'; + require_once 'HTTP/Request2/MultipartBody.php'; + require_once 'HTTP/Request2/Response.php'; + require_once 'HTTP/Request2/Adapter/Mock.php'; + require_once 'HTTP/Request2/Adapter/Socket.php'; + require_once 'HTTP/Request2/Observer/UncompressingDownload.php'; + $installed = true; + +} else { + $installed = false; + foreach (__DIR__ . '/../../../autoload.php', __DIR__ . '/../vendor/autoload.php' as $file) { + if (file_exists($file)) { + // found composer autoloader, use it + require_once $file; + $installed = true; + + break; + } + } +} + +if (!$installed) { + fwrite(STDERR, + 'As HTTP_Request2 has required dependencies, tests should be run either' . PHP_EOL . PHP_EOL . + ' - after installation of package with PEAR:' . PHP_EOL . + ' pear install package.xml' . PHP_EOL . PHP_EOL . + ' - or setting up its dependencies using Composer:' . PHP_EOL . + ' composer install' . PHP_EOL . PHP_EOL + ); + + die(1); +} + +if (!defined('HTTP_REQUEST2_TESTS_BASE_URL')) { + if (is_readable(__DIR__ . '/NetworkConfig.php')) { + require_once __DIR__ . '/NetworkConfig.php'; + } else { + require_once __DIR__ . '/NetworkConfig.php.dist'; + } +} +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_files/bug_15305
Changed
(renamed from HTTP_Request2-2.3.0/tests/_files/bug_15305)
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_files/bug_18169
Changed
(renamed from HTTP_Request2-2.3.0/tests/_files/bug_18169)
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_files/empty.gif
Changed
(renamed from HTTP_Request2-2.3.0/tests/_files/empty.gif)
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_files/plaintext.txt
Changed
(renamed from HTTP_Request2-2.3.0/tests/_files/plaintext.txt)
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_files/response_cookies
Changed
(renamed from HTTP_Request2-2.3.0/tests/_files/response_cookies)
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_files/response_deflate
Changed
(renamed from HTTP_Request2-2.3.0/tests/_files/response_deflate)
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_files/response_gzip
Changed
(renamed from HTTP_Request2-2.3.0/tests/_files/response_gzip)
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_files/response_gzip_broken
Changed
(renamed from HTTP_Request2-2.3.0/tests/_files/response_gzip_broken)
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_files/response_headers
Changed
(renamed from HTTP_Request2-2.3.0/tests/_files/response_headers)
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/basicauth.php
Added
@@ -0,0 +1,33 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +$user = isset($_SERVER'PHP_AUTH_USER') ? $_SERVER'PHP_AUTH_USER' : null; +$pass = isset($_SERVER'PHP_AUTH_PW') ? $_SERVER'PHP_AUTH_PW' : null; +$wantedUser = isset($_GET'user') ? $_GET'user' : null; +$wantedPass = isset($_GET'pass') ? $_GET'pass' : null; + +if (!$user || !$pass || $user != $wantedUser || $pass != $wantedPass) { + header('WWW-Authenticate: Basic realm="HTTP_Request2 tests"', true, 401); + echo "Login required"; +} else { + echo "Username={$user};Password={$pass}"; +} + +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/bug19934.php
Added
@@ -0,0 +1,27 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +for ($i = 0; $i < 20; $i++) { + for ($j = 0; $j < 10; $j++) { + echo str_repeat((string)$j, 98) . "\r\n"; + } + flush(); + usleep(50000); +} \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/bug20228.php
Added
@@ -0,0 +1,24 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +header('Transfer-Encoding: chunked'); + +echo "e\r\n"; +echo "This is a test\r\n";
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/cookies.php
Added
@@ -0,0 +1,24 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +ksort($_COOKIE); +echo serialize($_COOKIE); + +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/digestauth.php
Added
@@ -0,0 +1,83 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +/** + * Mostly borrowed from PHP manual and Socket Adapter implementation + * + * @link http://php.net/manual/en/features.http-auth.php + */ + +/** + * Parses the Digest auth header + * + * @param string $txt + */ +function http_digest_parse($txt) +{ + $token = '^\x00-\x1f\x7f-\xff()<>@,;:\\\\"/\\?={}\s+'; + $quoted = '"(?:\\\\.|^\\\\")*"'; + + // protect against missing data + $needed_parts = array_flip('nonce', 'nc', 'cnonce', 'qop', 'username', 'uri', 'response'); + $data = ; + + preg_match_all("!({$token})\\s*=\\s*({$token}|{$quoted})!", $txt, $matches); + for ($i = 0; $i < count($matches0); $i++) { + // ignore unneeded parameters + if (isset($needed_parts$matches1$i)) { + unset($needed_parts$matches1$i); + if ('"' == substr($matches2$i, 0, 1)) { + $data$matches1$i = substr($matches2$i, 1, -1); + } else { + $data$matches1$i = $matches2$i; + } + } + } + + return !empty($needed_parts) ? false : $data; +} + +$realm = 'HTTP_Request2 tests'; +$wantedUser = isset($_GET'user') ? $_GET'user' : null; +$wantedPass = isset($_GET'pass') ? $_GET'pass' : null; +$validAuth = false; + +if (!empty($_SERVER'PHP_AUTH_DIGEST') + && ($data = http_digest_parse($_SERVER'PHP_AUTH_DIGEST')) + && $wantedUser == $data'username' +) { + // generate the valid response + $a1 = md5($data'username' . ':' . $realm . ':' . $wantedPass); + $a2 = md5($_SERVER'REQUEST_METHOD' . ':' . $data'uri'); + $response = md5($a1. ':' . $data'nonce' . ':' . $data'nc' . ':' + . $data'cnonce' . ':' . $data'qop' . ':' . $a2); + + // check valid response against existing one + $validAuth = ($data'response' == $response); +} + +if (!$validAuth || empty($_SERVER'PHP_AUTH_DIGEST')) { + header('WWW-Authenticate: Digest realm="' . $realm . + '",qop="auth",nonce="' . uniqid() . '"', true, 401); + echo "Login required"; +} else { + echo "Username={$data'username'}"; +} +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/download.php
Added
@@ -0,0 +1,45 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +$payload = str_repeat('0123456789abcdef', 128); + +if (array_key_exists('gzip', $_GET)) { + // we inject a long "filename" into the header to check whether the downloader + // can handle an incomplete header in "slowpoke" mode + $payload = pack('c4Vc2', 0x1f, 0x8b, 8, 8, time(), 2, 255) + . str_repeat('a_really_really_long_file_name', 10) . '.txt' . chr(0) + . gzdeflate($payload) + . pack('V2', crc32($payload), 2048); + header('Content-Encoding: gzip'); +} + +if (!array_key_exists('slowpoke', $_GET)) { + echo $payload; + +} else { + $pos = 0; + $length = strlen($payload); + while ($pos < $length) { + echo substr($payload, $pos, 65); + $pos += 65; + flush(); + usleep(50000); + } +} \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/getparameters.php
Added
@@ -0,0 +1,24 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +ksort($_GET); +echo serialize($_GET); + +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/incompletebody.php
Added
@@ -0,0 +1,32 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +header('Connection: close'); + +if (array_key_exists('chunked', $_GET)) { + header('Transfer-Encoding: chunked'); + echo "2A\r\n"; + +} else { + header('Content-Length: 42'); +} + +echo "This is a test"; +flush(); \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/postparameters.php
Added
@@ -0,0 +1,24 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +ksort($_POST); +echo serialize($_POST); + +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/rawpostdata.php
Added
@@ -0,0 +1,22 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +readfile('php://input'); +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/redirects.php
Added
@@ -0,0 +1,50 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +$redirects = isset($_GET'redirects')? $_GET'redirects': 1; +$https = !empty($_SERVER'HTTPS') && ('off' != strtolower($_SERVER'HTTPS')); +$special = isset($_GET'special')? $_GET'special': null; + +if ('ftp' == $special) { + header('Location: ftp://localhost/pub/exploit.exe', true, 301); + +} elseif ('youtube' == $special) { + header('Location: https://youtube.com/', true, 301); + +} elseif ('relative' == $special) { + header('Location: ./getparameters.php?msg=did%20relative%20redirect', true, 302); + +} elseif ('cookie' == $special) { + setcookie('cookie_on_redirect', 'success'); + header('Location: ./cookies.php', true, 302); + +} elseif ($redirects > 0) { + $url = ($https? 'https': 'http') . '://' . $_SERVER'SERVER_NAME' + . (($https && 443 == $_SERVER'SERVER_PORT' || !$https && 80 == $_SERVER'SERVER_PORT') + ? '' : ':' . $_SERVER'SERVER_PORT') + . $_SERVER'PHP_SELF' . '?redirects=' . (--$redirects); + header('Location: ' . $url, true, 302); + +} else { + echo "Method=" . $_SERVER'REQUEST_METHOD' . ';'; + var_dump($_POST); + var_dump($_GET); +} +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/setcookie.php
Added
@@ -0,0 +1,27 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +$name = empty($_GET'name')? 'foo': $_GET'name'; +$value = empty($_GET'value')? 'bar': $_GET'value'; + +setcookie($name, $value); + +echo "Cookie set!"; +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/timeout.php
Added
@@ -0,0 +1,23 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +sleep(5); + +?> \ No newline at end of file
View file
HTTP_Request2-2.6.0.tgz/HTTP_Request2-2.6.0/tests/_network/uploads.php
Added
@@ -0,0 +1,34 @@ +<?php +/** + * Helper files for HTTP_Request2 unit tests. Should be accessible via HTTP. + * + * PHP version 5 + * + * LICENSE + * + * 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 + * + * @category HTTP + * @package HTTP_Request2 + * @author Alexey Borzov <avb@php.net> + * @copyright 2008-2023 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 + */ + +if (isset($_GET'slowpoke')) { + sleep(3); +} + +foreach ($_FILES as $name => $file) { + if (is_array($file'name')) { + foreach($file'name' as $k => $v) { + echo "{$name}{$k} {$v} {$file'type'$k} {$file'size'$k}\n"; + } + } else { + echo "{$name} {$file'name'} {$file'type'} {$file'size'}\n"; + } +} +?> \ No newline at end of file
View file
HTTP_Request2-2.3.0.tgz/package.xml -> HTTP_Request2-2.6.0.tgz/package.xml
Changed
@@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ISO-8859-1"?> -<package packagerversion="1.9.5" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> +<package packagerversion="1.10.13" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 http://pear.php.net/dtd/package-2.0.xsd"> <name>HTTP_Request2</name> <channel>pear.php.net</channel> <extends>HTTP_Request</extends> @@ -18,11 +18,11 @@ <email>avb@php.net</email> <active>yes</active> </lead> - <date>2016-02-13</date> - <time>20:23:34</time> + <date>2023-11-01</date> + <time>20:03:16</time> <version> - <release>2.3.0</release> - <api>2.3.0</api> + <release>2.6.0</release> + <api>2.4.0</api> </version> <stability> <release>stable</release> @@ -30,74 +30,64 @@ </stability> <license uri="http://opensource.org/licenses/BSD-3-Clause">BSD 3-Clause License</license> <notes> -New features: - * New observer that can do on-the-fly decoding of compressed responses, - see HTTP_Request2_Observer_UncompressingDownload. - Thanks to Delian Krustev for initial implementation. - * CookieJar can now silently ignore invalid cookies with $jar->ignoreInvalidCookies(true); - instead of throwing an exception. See requests #19937 and #20401 - * Adapters now dispatch a new 'warning' event, e.g. in case of incomplete response - body or broken 'chunked' encoding. Exception was thrown previously by Socket adapter - in the latter case, see bug #20228 - * Improved security of HTTPS requests in Socket adapter - - Use 'tls://' instead of 'ssl://' in connection string to prevent fallback to - known insecure versions, use only TLS when enabling crypto via proxy (see bug #20462) - - On PHP 5.6+ require using only TLS 1.1 and TLS 1.2 - - Do not use insecure ciphers - * Improved test suite, network-backed tests now run on Travis CI - -Changes and fixes: - * Curl adapter failed to send PUT request body with 'follow_redirects' on (bug #20440) - * Curl adapter supplied invalid cookie domain to CookieJar after redirect (bug #20561) - * Curl adapter now properly dispatches events while sending the request - * mime_content_type() returning false was handled incorrectly when guessing content-type - * Use 'peer_name' and 'verify_peer_name' SSL context options on PHP 5.6+ - instead of deprecated 'CN_match' - * Public Suffix List updated to current version, its download location changed - -Note to Composer users: next package version will probably get rid of 'include-path' -setting in composer.json favour of using autoloader. +* Tested on PHP 8.2 and 8.3 +* Use psalm for static analysis, several minor issues fixed +* Correctly parse HTTP status line with an empty reason-phrase + (see https://github.com/pear/HTTP_Request2/pull/26) +* Updated Public Suffix List </notes> <contents> <dir name="/"> - <file md5sum="ff31b30d8df996defb7b608d6d2db1e1" name="HTTP/Request2/Adapter/Curl.php" role="php"> + <file md5sum="81b94fe3f5aad81231fe5c5440b7cbbb" name="HTTP/Request2/Adapter/Curl.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file md5sum="2c606ad03c86bf425d56efebedb97331" name="HTTP/Request2/Adapter/Mock.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="202012330e01073212804fd9e2a1cc31" name="HTTP/Request2/Adapter/Mock.php" role="php"> + <file md5sum="1bc53a7d450ae228d103a6a2ee5a40c8" name="HTTP/Request2/Adapter/Socket.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="e2b21b1eea2f0295e43d9477e881bb9f" name="HTTP/Request2/Adapter/Socket.php" role="php"> + <file md5sum="3df137bc6a2d9667f56cb92c6bea726a" name="HTTP/Request2/Observer/Log.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="10237a9d6822757bd717d53acf211b8a" name="HTTP/Request2/Observer/Log.php" role="php"> + <file md5sum="e3268a3edaac30a2656038625a233229" name="HTTP/Request2/Observer/UncompressingDownload.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="8d272f33494040c346fbd89fd7edaf8a" name="HTTP/Request2/Observer/UncompressingDownload.php" role="php"> + <file md5sum="b2b2c26afad5f85eff31bde32922a60a" name="HTTP/Request2/Adapter.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="3325b0f4933fd013e9a6ce4953bcb75b" name="HTTP/Request2/Adapter.php" role="php"> + <file md5sum="d358858512d2f79bac5803b42471e978" name="HTTP/Request2/ConnectionException.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="e06b17a767c0778ca1be0942f5ae7d1d" name="HTTP/Request2/CookieJar.php" role="php"> + <file md5sum="6761ec824b7eb6a4608a95979e63902d" name="HTTP/Request2/CookieJar.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> <tasks:replace from="@data_dir@" to="data_dir" type="pear-config" /> </file> - <file md5sum="d4f7e1d9a30bf0fa02a2d6ae3c553223" name="HTTP/Request2/Exception.php" role="php"> + <file md5sum="82dfe4edf7760cb4d8912f050644251a" name="HTTP/Request2/Exception.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file md5sum="24385fe0eefe7869a5921ce7ac8030c5" name="HTTP/Request2/LogicException.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file md5sum="bed90ef51aecf640f4a0e70b5b6be2ab" name="HTTP/Request2/MessageException.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="fffe7e58f3e45dd54b0d32a8e66ff21b" name="HTTP/Request2/MultipartBody.php" role="php"> + <file md5sum="5c1cae794cd7bda24730c6d253e5c6eb" name="HTTP/Request2/MultipartBody.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="f332e47d535d68d799016b77bbcebc31" name="HTTP/Request2/SocketWrapper.php" role="php"> + <file md5sum="606b8ac8903b169894dbc919922fe394" name="HTTP/Request2/NotImplementedException.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="85ab1e0fb01171adb854185ba0bb3757" name="HTTP/Request2/SOCKS5.php" role="php"> + <file md5sum="29ed9a6a30e8a7baeb61798c2b3dc9dd" name="HTTP/Request2/SocketWrapper.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="f07cc69f5af8201bfc9250cd4d8466b5" name="HTTP/Request2/Response.php" role="php"> + <file md5sum="ab45f702ad91928d5f2ed8b71fc17fc1" name="HTTP/Request2/SOCKS5.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="95d0943f0e31e570c138f56e37b5b1b9" name="HTTP/Request2.php" role="php"> + <file md5sum="8ea0569b63a7c01bbe9489aa100428e4" name="HTTP/Request2/Response.php" role="php"> + <tasks:replace from="@package_version@" to="version" type="package-info" /> + </file> + <file md5sum="878c0ecc74ef8f400832a58175ff52dc" name="HTTP/Request2.php" role="php"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> <file md5sum="22d7f11b85dd00bd8919a4226a5a0388" name="tests/_files/bug_15305" role="test" /> @@ -109,48 +99,49 @@ <file md5sum="c36530c79c044fde1745b244c38d381f" name="tests/_files/response_gzip" role="test" /> <file md5sum="722328bfe89a9c9f7de5a020ed2c4589" name="tests/_files/response_gzip_broken" role="test" /> <file md5sum="1fb55dfe18831f8fe6280280e72ad216" name="tests/_files/response_headers" role="test" /> - <file md5sum="ad304b4f6438fa6fb9d89a8145032dd0" name="tests/_network/basicauth.php" role="test" /> - <file md5sum="68fa92c224d8946a1b231456fbb224a3" name="tests/_network/bug19934.php" role="test" /> - <file md5sum="aa222585358077911072f3dd0c42df9e" name="tests/_network/bug20228.php" role="test" /> - <file md5sum="865a3d4456fc408254e0fa6736216f19" name="tests/_network/cookies.php" role="test" /> - <file md5sum="e0009b1b032491bc8257cdf6178f25de" name="tests/_network/digestauth.php" role="test" /> - <file md5sum="30490b1f1be793b920d7fd9c0b175b45" name="tests/_network/download.php" role="test" /> - <file md5sum="a82c3f9cf27a44b198e5f93a90bc96b3" name="tests/_network/getparameters.php" role="test" /> - <file md5sum="70be2bfd73621dcd5e90cb33fafcf104" name="tests/_network/incompletebody.php" role="test" /> - <file md5sum="de962e4a76f01ff24a47d0480f10ce48" name="tests/_network/postparameters.php" role="test" /> - <file md5sum="89ae150b707a7972a131036439950d03" name="tests/_network/rawpostdata.php" role="test" /> - <file md5sum="eb62599fc9b811da4393c8e87ae2140b" name="tests/_network/redirects.php" role="test" /> - <file md5sum="51d61e300459c69c6071495f0748c624" name="tests/_network/setcookie.php" role="test" /> - <file md5sum="a35c31d0b53a9fc00c5ada155489a966" name="tests/_network/timeout.php" role="test" /> - <file md5sum="32a9e4b93ebbfef839e032332d75d39f" name="tests/_network/uploads.php" role="test" /> - <file md5sum="b29f96cb193b877fa07679db536cd20f" name="tests/Request2/Adapter/AllTests.php" role="test" /> - <file md5sum="55cf05d4285a5c9cb52a0116c476f5ef" name="tests/Request2/Adapter/CommonNetworkTest.php" role="test" /> - <file md5sum="a3ba6aa11bc67f2a3f302d6ada41f296" name="tests/Request2/Adapter/CurlTest.php" role="test" /> - <file md5sum="981e65e64ec10ded190cdeb7f4855307" name="tests/Request2/Adapter/MockTest.php" role="test" /> - <file md5sum="2d71de555a33b7b250bc1278b23f6806" name="tests/Request2/Adapter/SkippedTests.php" role="test" /> - <file md5sum="91374b3099989349963f0e17c7842ac7" name="tests/Request2/Adapter/SocketProxyTest.php" role="test" /> - <file md5sum="516895325ec84457932f0f82ec69678b" name="tests/Request2/Adapter/SocketTest.php" role="test" /> - <file md5sum="dda9904272b1bba42bd8a972b221a0eb" name="tests/Request2/AllTests.php" role="test" /> - <file md5sum="232d4db37a3cdc3779e40ae6113047cb" name="tests/Request2/CookieJarTest.php" role="test" /> - <file md5sum="481cc1a17ed65eba0b10a8916228ab03" name="tests/Request2/MultipartBodyTest.php" role="test" /> - <file md5sum="b47370213741960d7046354c13fc601c" name="tests/Request2/ResponseTest.php" role="test" /> - <file md5sum="eef194a01abd27faba5dcda848520450" name="tests/AllTests.php" role="test" /> - <file md5sum="b2e41760e4dda3db9534880286ecad2f" name="tests/NetworkConfig.php.dist" role="test" /> - <file md5sum="55622a56b671b8c5aaad4b6e6be96956" name="tests/ObserverTest.php" role="test" /> - <file md5sum="78e1ad02e00b16c688e00539091802ab" name="tests/Request2Test.php" role="test" /> - <file md5sum="2d8b1c14b500e6002d54285a875cc988" name="tests/TestHelper.php" role="test"> + <file md5sum="1300ecb05dcfbfd0f660d85f7b822f75" name="tests/_network/basicauth.php" role="test" /> + <file md5sum="57a14362482d07c4cb65efd88af82aad" name="tests/_network/bug19934.php" role="test" /> + <file md5sum="046ec21ddb24d17de11191142f17634e" name="tests/_network/bug20228.php" role="test" /> + <file md5sum="d936464dcbfe85db34a5e9e0caf3f09b" name="tests/_network/cookies.php" role="test" /> + <file md5sum="28072362d7978dbf45326dfb365d7c50" name="tests/_network/digestauth.php" role="test" /> + <file md5sum="743e78c9b9228d1587cfc560b524c005" name="tests/_network/download.php" role="test" /> + <file md5sum="025f47711d0cbfa81c22281514b03098" name="tests/_network/getparameters.php" role="test" /> + <file md5sum="559b6c355e6808b4a05d4cbcc8de9c8b" name="tests/_network/incompletebody.php" role="test" /> + <file md5sum="76fc75c6690831078c04c683004ac529" name="tests/_network/postparameters.php" role="test" /> + <file md5sum="c7b06c6a61e1117d5593f2328b7df69d" name="tests/_network/rawpostdata.php" role="test" /> + <file md5sum="9bcac94a128f4ca48d03673150dc0355" name="tests/_network/redirects.php" role="test" /> + <file md5sum="fdbad4b54f39dd99a7db23131ea5a608" name="tests/_network/setcookie.php" role="test" /> + <file md5sum="c0b58a16f0d6f33d01a779d3ef098cd3" name="tests/_network/timeout.php" role="test" /> + <file md5sum="a6e122470853fff67d412f3267479bcf" name="tests/_network/uploads.php" role="test" /> + <file md5sum="fe63a10112291a44572e3fa4bc2bcc07" name="tests/Request2/Adapter/CommonNetworkTest.php" role="test" /> + <file md5sum="df55d1a4335fb6f5041db986fc7e0f7a" name="tests/Request2/Adapter/CurlTest.php" role="test" /> + <file md5sum="10763c9aee1d48dd43d1433bca830456" name="tests/Request2/Adapter/EventSequenceObserver.php" role="test" /> + <file md5sum="7e75eee398c4a90d98e1bef6efa5b139" name="tests/Request2/Adapter/HeaderObserver.php" role="test" /> + <file md5sum="13375bb49ce5fc15bb9868e8c0dbb7e8" name="tests/Request2/Adapter/MockTest.php" role="test" /> + <file md5sum="93cac67453e3b636d898601ec7001d55" name="tests/Request2/Adapter/SlowpokeBody.php" role="test" /> + <file md5sum="89df375c49efdd2d043eebb841b911d0" name="tests/Request2/Adapter/SocketProxyTest.php" role="test" /> + <file md5sum="d9a077b6938c1d7915de8933ae123f46" name="tests/Request2/Adapter/SocketTest.php" role="test" /> + <file md5sum="ab9b010f059b8936535349d1e851f27b" name="tests/Request2/Adapter/UploadSizeObserver.php" role="test" /> + <file md5sum="b28285f3d28e7e83661432a09f3bc9bb" name="tests/Request2/CookieJarTest.php" role="test" /> + <file md5sum="299dc04dbb9d19ca4ff7804e771d8ed8" name="tests/Request2/MultipartBodyTest.php" role="test" /> + <file md5sum="955c6bad2aadb8abb3068ca93b4709c3" name="tests/Request2/ResponseTest.php" role="test" /> + <file md5sum="6e297ef4f197bf35bab38a8907ae38e4" name="tests/MockObserver.php" role="test" /> + <file md5sum="5c8d0c9a0dbaaa41a07606b5ca1e9126" name="tests/NetworkConfig.php.dist" role="test" /> + <file md5sum="1c9e41a433df231a6cffd3955fc472b7" name="tests/ObserverTest.php" role="test" /> + <file md5sum="05bf285854eb50d0c8e1f74a1f65ccd5" name="tests/Request2Test.php" role="test" /> + <file md5sum="236caed62ad058509e62c68476bd1789" name="tests/TestHelper.php" role="test"> <tasks:replace from="@package_version@" to="version" type="package-info" /> </file> - <file md5sum="02589df0c03918eb53366867e4649031" name="docs/LICENSE" role="doc" /> - <file md5sum="4bf3cf43f9053b41181b9008c8f20c5a" name="docs/examples/upload-rapidshare.php" role="doc" /> - <file md5sum="7a4c1c26722b93b637655610d0fc93f5" name="data/generate-list.php" role="data" /> - <file md5sum="cbb73ce35ae899857acb93bc64855744" name="data/public-suffix-list.php" role="data" /> + <file md5sum="9de7b683e45c54d5d091d017e077ea70" name="docs/LICENSE" role="doc" />
View file
debian.changelog
Changed
@@ -1,3 +1,9 @@ +php-http-request2 (2.6.0-1~kolab1) unstable; urgency=medium + + * Update to 2.6.0 + + -- Christoph Erhardt <kolab@sicherha.de> Tue, 09 Jul 2024 23:11:01 +0200 + php-http-request2 (2.3.0-1~kolab1) unstable; urgency=medium * Package for Kolab
View file
php-http-request2.dsc
Changed
@@ -2,7 +2,7 @@ Source: php-http-request2 Binary: php-http-request2 Architecture: all -Version: 2.3.0-1~kolab1 +Version: 2.6.0-1~kolab1 Maintainer: Debian PHP PEAR Maintainers <pkg-php-pear@lists.alioth.debian.org> Uploaders: Sascha Girrulat <sascha@girrulat.de> Homepage: http://pear.php.net/package/HTTP_Request2/
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.