From 4e4777e01b6c881cfe64db4ed308cd00ea18e375 Mon Sep 17 00:00:00 2001 From: Duncan Cameron <3147688+bramley@users.noreply.github.com> Date: Fri, 13 Jan 2023 15:55:47 +0000 Subject: [PATCH] Update PEAR HTTP_Request2 package to version 2.5.1 (#921) --- .../lists/admin/PEAR/HTTP/Request2.php | 174 +++++++++++------- .../admin/PEAR/HTTP/Request2/Adapter.php | 30 +-- .../admin/PEAR/HTTP/Request2/Adapter/Curl.php | 89 +++++---- .../admin/PEAR/HTTP/Request2/Adapter/Mock.php | 26 +-- .../PEAR/HTTP/Request2/Adapter/Socket.php | 129 +++++++------ .../HTTP/Request2/ConnectionException.php | 4 +- .../admin/PEAR/HTTP/Request2/CookieJar.php | 65 +++++-- .../admin/PEAR/HTTP/Request2/Exception.php | 41 +++-- .../PEAR/HTTP/Request2/LogicException.php | 4 +- .../PEAR/HTTP/Request2/MessageException.php | 4 +- .../PEAR/HTTP/Request2/MultipartBody.php | 35 ++-- .../HTTP/Request2/NotImplementedException.php | 4 +- .../admin/PEAR/HTTP/Request2/Observer/Log.php | 15 +- .../Observer/UncompressingDownload.php | 27 ++- .../admin/PEAR/HTTP/Request2/Response.php | 65 ++++--- .../lists/admin/PEAR/HTTP/Request2/SOCKS5.php | 8 +- .../PEAR/HTTP/Request2/SocketWrapper.php | 63 +++++-- 17 files changed, 482 insertions(+), 301 deletions(-) diff --git a/public_html/lists/admin/PEAR/HTTP/Request2.php b/public_html/lists/admin/PEAR/HTTP/Request2.php index 5853c663a..1aec9289e 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -35,13 +35,14 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @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 @@ -54,25 +55,32 @@ class HTTP_Request2 implements SplSubject 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 */ @@ -80,46 +88,53 @@ class HTTP_Request2 implements SplSubject /** * Fileinfo magic database resource - * @var resource - * @see detectMimeType() + * + * @var resource + * @see detectMimeType() */ private static $_fileinfoDb; /** * Observers attached to the request (instances of SplObserver) - * @var array + * + * @var array */ protected $observers = []; /** * Request URL - * @var Net_URL2 + * + * @var Net_URL2 */ protected $url; /** * Request method - * @var string + * + * @var string */ protected $method = self::METHOD_GET; /** * Authentication data - * @var array - * @see getAuth() + * + * @var array + * @see getAuth() */ protected $auth; /** * Request headers - * @var array + * + * @var array */ protected $headers = []; /** * Configuration parameters - * @var array - * @see setConfig() + * + * @var array + * @see setConfig() */ protected $config = [ 'adapter' => 'HTTP_Request2_Adapter_Socket', @@ -154,8 +169,9 @@ class HTTP_Request2 implements SplSubject /** * Last event in request / response handling, intended for observers - * @var array - * @see getLastEvent() + * + * @var array + * @see getLastEvent() */ protected $lastEvent = [ 'name' => 'start', @@ -164,31 +180,36 @@ class HTTP_Request2 implements SplSubject /** * Request body - * @var string|resource - * @see setBody() + * + * @var string|resource + * @see setBody() */ protected $body = ''; /** * Array of POST parameters - * @var array + * + * @var array */ protected $postParams = []; /** * Array of file uploads (for multipart/form-data POST requests) - * @var array + * + * @var array */ protected $uploads = []; /** * Adapter used to perform actual HTTP request - * @var HTTP_Request2_Adapter + * + * @var HTTP_Request2_Adapter */ protected $adapter; /** * Cookie jar to persist cookies between requests + * * @var HTTP_Request2_CookieJar */ protected $cookieJar = null; @@ -213,8 +234,8 @@ public function __construct( $this->setMethod($method); } $this->setHeader( - 'user-agent', 'HTTP_Request2/2.4.2 ' . - '(http://pear.php.net/package/http_request2) PHP/' . phpversion() + 'user-agent', 'HTTP_Request2/2.5.1 ' . + '(https://github.com/pear/HTTP_Request2) PHP/' . phpversion() ); } @@ -227,8 +248,8 @@ public function __construct( * * @param string|Net_URL2 $url Request URL * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException + * @return $this + * @throws HTTP_Request2_LogicException */ public function setUrl($url) { @@ -261,7 +282,7 @@ public function setUrl($url) /** * Returns the request URL * - * @return Net_URL2 + * @return Net_URL2 */ public function getUrl() { @@ -273,8 +294,8 @@ public function getUrl() * * @param string $method one of the methods defined in RFC 2616 * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException if the method name is invalid + * @return $this + * @throws HTTP_Request2_LogicException if the method name is invalid */ public function setMethod($method) { @@ -293,7 +314,7 @@ public function setMethod($method) /** * Returns the request method * - * @return string + * @return string */ public function getMethod() { @@ -351,8 +372,8 @@ public function getMethod() * ('parameter name' => 'parameter value') * @param mixed $value parameter value if $nameOrConfig is not an array * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException If the parameter is unknown + * @return $this + * @throws HTTP_Request2_LogicException If the parameter is unknown */ public function setConfig($nameOrConfig, $value = null) { @@ -363,13 +384,15 @@ public function setConfig($nameOrConfig, $value = null) } elseif ('proxy' == $nameOrConfig) { $url = new Net_URL2($value); - $this->setConfig([ - 'proxy_type' => $url->getScheme(), - 'proxy_host' => $url->getHost(), - 'proxy_port' => $url->getPort(), - 'proxy_user' => rawurldecode($url->getUser()), - 'proxy_password' => rawurldecode($url->getPassword()) - ]); + $this->setConfig( + [ + 'proxy_type' => $url->getScheme(), + 'proxy_host' => $url->getHost(), + 'proxy_port' => $url->getPort(), + 'proxy_user' => rawurldecode($url->getUser()), + 'proxy_password' => rawurldecode($url->getPassword()) + ] + ); } else { if (!array_key_exists($nameOrConfig, $this->config)) { @@ -389,9 +412,9 @@ public function setConfig($nameOrConfig, $value = null) * * @param string $name parameter name * - * @return mixed value of $name parameter, array of all configuration + * @return mixed value of $name parameter, array of all configuration * parameters if $name is not given - * @throws HTTP_Request2_LogicException If the parameter is unknown + * @throws HTTP_Request2_LogicException If the parameter is unknown */ public function getConfig($name = null) { @@ -407,13 +430,13 @@ public function getConfig($name = null) } /** - * Sets the autentification data + * Sets the authentication data * * @param string $user user name * @param string $password password * @param string $scheme authentication scheme * - * @return HTTP_Request2 + * @return $this */ public function setAuth($user, $password = '', $scheme = self::AUTH_BASIC) { @@ -436,7 +459,7 @@ public function setAuth($user, $password = '', $scheme = self::AUTH_BASIC) * The array has the keys 'user', 'password' and 'scheme', where 'scheme' * is one of the HTTP_Request2::AUTH_* constants. * - * @return array + * @return array */ public function getAuth() { @@ -468,8 +491,8 @@ public function getAuth() * @param bool $replace whether to replace previous header with the * same name or append to its value * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException + * @return $this + * @throws HTTP_Request2_LogicException */ public function setHeader($name, $value = null, $replace = true) { @@ -520,7 +543,7 @@ public function setHeader($name, $value = null, $replace = true) * The array is of the form ('header name' => 'header value'), header names * are lowercased * - * @return array + * @return array */ public function getHeaders() { @@ -541,9 +564,9 @@ public function getHeaders() * @param string $name cookie name * @param string $value cookie value * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException - * @see setCookieJar() + * @return $this + * @throws HTTP_Request2_LogicException + * @see setCookieJar() */ public function addCookie($name, $value) { @@ -574,13 +597,13 @@ public function addCookie($name, $value) * fstat() and rewind() operations. * * @param string|resource|HTTP_Request2_MultipartBody $body Either a - * string with the body or filename containing body or - * pointer to an open file or object with multipart body data + * string with the body or filename containing body or + * pointer to an open file or object with multipart body data * @param bool $isFilename Whether - * first parameter is a filename + * first parameter is a filename * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException + * @return $this + * @throws HTTP_Request2_LogicException */ public function setBody($body, $isFilename = false) { @@ -605,7 +628,7 @@ public function setBody($body, $isFilename = false) /** * Returns the request body * - * @return string|resource|HTTP_Request2_MultipartBody + * @return string|resource|HTTP_Request2_MultipartBody */ public function getBody() { @@ -644,12 +667,12 @@ public function getBody() * * @param string $fieldName name of file-upload field * @param string|resource|array $filename full name of local file, - * pointer to open file or an array of files + * pointer to open file or an array of files * @param string $sendFilename filename to send in the request * @param string $contentType content-type of file being uploaded * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException + * @return $this + * @throws HTTP_Request2_LogicException */ public function addUpload( $fieldName, $filename, $sendFilename = null, $contentType = null @@ -695,7 +718,7 @@ public function addUpload( * @param string|array $name parameter name or array ('name' => 'value') * @param mixed $value parameter value (can be an array) * - * @return HTTP_Request2 + * @return $this */ public function addPostParameter($name, $value = null) { @@ -713,10 +736,13 @@ public function addPostParameter($name, $value = null) return $this; } + #[ReturnTypeWillChange] /** * Attaches a new observer * * @param SplObserver $observer any object implementing SplObserver + * + * @return void */ public function attach(SplObserver $observer) { @@ -728,10 +754,13 @@ public function attach(SplObserver $observer) $this->observers[] = $observer; } + #[ReturnTypeWillChange] /** * Detaches an existing observer * * @param SplObserver $observer any object implementing SplObserver + * + * @return void */ public function detach(SplObserver $observer) { @@ -743,8 +772,11 @@ public function detach(SplObserver $observer) } } + #[ReturnTypeWillChange] /** * Notifies all observers + * + * @return void */ public function notify() { @@ -761,6 +793,8 @@ public function notify() * * @param string $name event name * @param mixed $data event data + * + * @return void */ public function setLastEvent($name, $data = null) { @@ -803,7 +837,7 @@ public function setLastEvent($name, $data = null) * Different adapters may not send all the event types. Mock adapter does * not send any events to the observers. * - * @return array The array has two keys: 'name' and 'data' + * @return array The array has two keys: 'name' and 'data' */ public function getLastEvent() { @@ -824,8 +858,8 @@ public function getLastEvent() * * @param string|HTTP_Request2_Adapter $adapter Adapter to use * - * @return HTTP_Request2 - * @throws HTTP_Request2_LogicException + * @return $this + * @throws HTTP_Request2_LogicException */ public function setAdapter($adapter) { @@ -869,7 +903,7 @@ public function setAdapter($adapter) * @param HTTP_Request2_CookieJar|bool $jar Existing CookieJar object, true to * create a new one, false to remove * - * @return HTTP_Request2 + * @return $this * @throws HTTP_Request2_LogicException */ public function setCookieJar($jar = true) @@ -905,8 +939,8 @@ public function getCookieJar() /** * Sends the request and returns the response * - * @throws HTTP_Request2_Exception - * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception + * @return HTTP_Request2_Response */ public function send() { @@ -947,8 +981,8 @@ public function send() * * @param string|resource $file file name or pointer to open file * @param bool $detectType whether to try autodetecting MIME - * type of file, will only work if $file is a - * filename, not pointer + * type of file, will only work if $file is a + * filename, not pointer * * @return array array('fp' => file pointer, 'size' => file size, 'type' => MIME type) * @throws HTTP_Request2_LogicException @@ -996,7 +1030,7 @@ protected function fopenWrapper($file, $detectType = false) * * @param string $filename file name * - * @return string file MIME type + * @return string file MIME type */ protected static function detectMimeType($filename) { diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/Adapter.php b/public_html/lists/admin/PEAR/HTTP/Request2/Adapter.php index aa10a1306..28bb1b0b2 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/Adapter.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/Adapter.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -34,14 +34,15 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @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 + * + * @var array */ protected static $bodyDisallowed = ['TRACE']; @@ -59,20 +60,23 @@ abstract class HTTP_Request2_Adapter /** * Request being sent - * @var HTTP_Request2 + * + * @var HTTP_Request2 */ protected $request; /** * Request body - * @var string|resource|HTTP_Request2_MultipartBody - * @see HTTP_Request2::getBody() + * + * @var string|resource|HTTP_Request2_MultipartBody + * @see HTTP_Request2::getBody() */ protected $requestBody; /** * Length of the request body - * @var integer + * + * @var integer */ protected $contentLength; @@ -81,17 +85,19 @@ abstract class HTTP_Request2_Adapter * * @param HTTP_Request2 $request HTTP request message * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception + * @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) + * @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) { diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Curl.php b/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Curl.php index 2d5898927..05a5d03a6 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Curl.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Curl.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -30,14 +30,15 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @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 + * + * @var array */ protected static $headerMap = [ 'accept-encoding' => CURLOPT_ENCODING, @@ -48,7 +49,8 @@ class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter /** * Mapping of SSL context options to cURL options - * @var array + * + * @var array */ protected static $sslContextMap = [ 'ssl_verify_peer' => CURLOPT_SSL_VERIFYPEER, @@ -60,7 +62,8 @@ class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter /** * Mapping of CURLE_* constants to Exception subclasses and error codes - * @var array + * + * @var array */ protected static $errorMap = [ CURLE_UNSUPPORTED_PROTOCOL => ['HTTP_Request2_MessageException', @@ -100,38 +103,44 @@ class HTTP_Request2_Adapter_Curl extends HTTP_Request2_Adapter /** * Response being received - * @var HTTP_Request2_Response + * + * @var HTTP_Request2_Response */ protected $response; /** * Whether 'sentHeaders' event was sent to observers - * @var boolean + * + * @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() + * + * @var integer + * @see callbackReadBody() */ protected $position = 0; /** * Information about last transfer, as returned by curl_getinfo() - * @var array + * + * @var array */ protected $lastInfo; @@ -161,8 +170,8 @@ protected static function wrapCurlError($ch) * * @param HTTP_Request2 $request HTTP request message * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception */ public function sendRequest(HTTP_Request2 $request) { @@ -208,7 +217,7 @@ public function sendRequest(HTTP_Request2 $request) /** * Returns information about last transfer * - * @return array associative array as returned by curl_getinfo() + * @return array associative array as returned by curl_getinfo() */ public function getInfo() { @@ -218,27 +227,29 @@ public function getInfo() /** * Creates a new cURL handle and populates it with data from the request * - * @return resource a cURL handle, as created by curl_init() - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_NotImplementedException + * @return resource a cURL handle, as created by curl_init() + * @throws HTTP_Request2_LogicException + * @throws HTTP_Request2_NotImplementedException */ protected function createCurlHandle() { $ch = curl_init(); - curl_setopt_array($ch, [ - // setup write callbacks - CURLOPT_HEADERFUNCTION => [$this, 'callbackWriteHeader'], - CURLOPT_WRITEFUNCTION => [$this, 'callbackWriteBody'], - // buffer size - CURLOPT_BUFFERSIZE => $this->request->getConfig('buffer_size'), - // connection timeout - CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'), - // save full outgoing headers, in case someone is interested - CURLINFO_HEADER_OUT => true, - // request url - CURLOPT_URL => $this->request->getUrl()->getUrl() - ]); + curl_setopt_array( + $ch, [ + // setup write callbacks + CURLOPT_HEADERFUNCTION => [$this, 'callbackWriteHeader'], + CURLOPT_WRITEFUNCTION => [$this, 'callbackWriteBody'], + // buffer size + CURLOPT_BUFFERSIZE => $this->request->getConfig('buffer_size'), + // connection timeout + CURLOPT_CONNECTTIMEOUT => $this->request->getConfig('connect_timeout'), + // save full outgoing headers, in case someone is interested + CURLINFO_HEADER_OUT => true, + // request url + CURLOPT_URL => $this->request->getUrl()->getUrl() + ] + ); // set up redirects if (!$this->request->getConfig('follow_redirects')) { @@ -399,8 +410,10 @@ protected function createCurlHandle() * and setting it as CURLOPT_POSTFIELDS, so it isn't recommended for large * file uploads, use Socket adapter instead. * - * @param resource $ch cURL handle - * @param array &$headers Request headers + * @param resource $ch cURL handle + * @param array $headers Request headers + * + * @return void */ protected function workaroundPhpBug47204($ch, &$headers) { @@ -409,7 +422,7 @@ protected function workaroundPhpBug47204($ch, &$headers) // https://pear.php.net/bugs/bug.php?id=20440 for PUTs if (!$this->request->getConfig('follow_redirects') && (!($auth = $this->request->getAuth()) - || HTTP_Request2::AUTH_DIGEST != $auth['scheme']) + || HTTP_Request2::AUTH_DIGEST !== $auth['scheme']) || HTTP_Request2::METHOD_POST !== $this->request->getMethod() ) { curl_setopt($ch, CURLOPT_READFUNCTION, [$this, 'callbackReadBody']); @@ -439,7 +452,7 @@ protected function workaroundPhpBug47204($ch, &$headers) * @param resource $fd file descriptor (not used) * @param integer $length maximum length of data to return * - * @return string part of the request body, up to $length bytes + * @return string part of the request body, up to $length bytes */ protected function callbackReadBody($ch, $fd, $length) { @@ -472,8 +485,8 @@ protected function callbackReadBody($ch, $fd, $length) * @param resource $ch cURL handle * @param string $string response header (with trailing CRLF) * - * @return integer number of bytes saved - * @see HTTP_Request2_Response::parseHeaderLine() + * @return integer number of bytes saved + * @see HTTP_Request2_Response::parseHeaderLine() */ protected function callbackWriteHeader($ch, $string) { @@ -548,9 +561,9 @@ protected function callbackWriteHeader($ch, $string) * @param resource $ch cURL handle (not used) * @param string $string part of the response body * - * @return integer number of bytes saved - * @throws HTTP_Request2_MessageException - * @see HTTP_Request2_Response::appendBody() + * @return integer number of bytes saved + * @throws HTTP_Request2_MessageException + * @see HTTP_Request2_Response::appendBody() */ protected function callbackWriteBody($ch, $string) { diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Mock.php b/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Mock.php index f9cace85e..7ac09b03b 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Mock.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Mock.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -44,14 +44,15 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @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 + * + * @var array */ protected $responses = []; @@ -65,8 +66,8 @@ class HTTP_Request2_Adapter_Mock extends HTTP_Request2_Adapter * * @param HTTP_Request2 $request HTTP request message * - * @return HTTP_Request2_Response - * @throws Exception + * @return HTTP_Request2_Response + * @throws Exception */ public function sendRequest(HTTP_Request2 $request) { @@ -102,7 +103,8 @@ public function sendRequest(HTTP_Request2 $request) * @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 + * @return void + * @throws HTTP_Request2_Exception */ public function addResponse($response, $url = null) { @@ -110,8 +112,8 @@ public function addResponse($response, $url = null) $response = self::createResponseFromString($response); } elseif (is_resource($response)) { $response = self::createResponseFromFile($response); - } elseif (!$response instanceof HTTP_Request2_Response && - !$response instanceof Exception + } elseif (!$response instanceof HTTP_Request2_Response + && !$response instanceof Exception ) { throw new HTTP_Request2_Exception('Parameter is not a valid response'); } @@ -123,8 +125,8 @@ public function addResponse($response, $url = null) * * @param string $str string containing HTTP response message * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception */ public static function createResponseFromString($str) { @@ -146,8 +148,8 @@ public static function createResponseFromString($str) * * @param resource $fp file pointer returned by fopen() * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception */ public static function createResponseFromFile($fp) { diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Socket.php b/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Socket.php index 883015d5f..9712bef0b 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Socket.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/Adapter/Socket.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -34,7 +34,7 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @link http://pear.php.net/package/HTTP_Request2 */ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter @@ -51,8 +51,9 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter /** * Connected sockets, needed for Keep-Alive support - * @var array - * @see connect() + * + * @var array + * @see connect() */ protected static $sockets = []; @@ -66,33 +67,37 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter * duplicate requests to digest-protected resources after we have already * received the challenge. * - * @var array + * @var array */ protected static $challenges = []; /** * Connected socket - * @var HTTP_Request2_SocketWrapper - * @see connect() + * + * @var HTTP_Request2_SocketWrapper + * @see connect() */ protected $socket; /** * Challenge used for server digest authentication - * @var array + * + * @var array */ protected $serverChallenge; /** * Challenge used for proxy digest authentication - * @var array + * + * @var array */ protected $proxyChallenge; /** * Remaining length of the current chunk, when reading chunked response - * @var integer - * @see readChunked() + * + * @var integer + * @see readChunked() */ protected $chunkLength = 0; @@ -102,12 +107,13 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter * Starts at 'max_redirects' configuration parameter and is reduced on each * subsequent redirect. An Exception will be thrown once it reaches zero. * - * @var integer + * @var integer */ protected $redirectCountdown = null; /** * Whether to wait for "100 Continue" response before sending request body + * * @var bool */ protected $expect100Continue = false; @@ -117,8 +123,8 @@ class HTTP_Request2_Adapter_Socket extends HTTP_Request2_Adapter * * @param HTTP_Request2 $request HTTP request message * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception */ public function sendRequest(HTTP_Request2 $request) { @@ -187,8 +193,8 @@ public function sendRequest(HTTP_Request2 $request) /** * Connects to the remote server * - * @return bool whether the connection can be persistent - * @throws HTTP_Request2_Exception + * @return bool whether the connection can be persistent + * @throws HTTP_Request2_Exception */ protected function connect() { @@ -336,8 +342,10 @@ protected function connect() * sees that we are connected to a proxy server (duh!) rather than the server * that presents its certificate. * - * @link http://tools.ietf.org/html/rfc2817#section-5.2 - * @throws HTTP_Request2_Exception + * @link http://tools.ietf.org/html/rfc2817#section-5.2 + * + * @return void + * @throws HTTP_Request2_Exception */ protected function establishTunnel() { @@ -362,33 +370,35 @@ protected function establishTunnel() * Checks whether current connection may be reused or should be closed * * @param boolean $requestKeepAlive whether connection could - * be persistent in the first place + * be persistent in the first place * @param HTTP_Request2_Response $response response object to check * - * @return boolean + * @return boolean */ protected function canKeepAlive($requestKeepAlive, HTTP_Request2_Response $response) { // Do not close socket on successful CONNECT request - if (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() + if (HTTP_Request2::METHOD_CONNECT === $this->request->getMethod() && 200 <= $response->getStatus() && 300 > $response->getStatus() ) { return true; } - $lengthKnown = 'chunked' == strtolower($response->getHeader('transfer-encoding')) + $lengthKnown = 'chunked' === strtolower($response->getHeader('transfer-encoding') ?: '') || null !== $response->getHeader('content-length') // no body possible for such responses, see also request #17031 - || HTTP_Request2::METHOD_HEAD == $this->request->getMethod() + || HTTP_Request2::METHOD_HEAD === $this->request->getMethod() || in_array($response->getStatus(), [204, 304]); - $persistent = 'keep-alive' == strtolower($response->getHeader('connection')) || + $persistent = 'keep-alive' === strtolower($response->getHeader('connection') ?: '') || (null === $response->getHeader('connection') && - '1.1' == $response->getVersion()); + '1.1' === $response->getVersion()); return $requestKeepAlive && $lengthKnown && $persistent; } /** * Disconnects from the remote server + * + * @return void */ protected function disconnect() { @@ -408,8 +418,8 @@ protected function disconnect() * @param HTTP_Request2 $request Original request * @param HTTP_Request2_Response $response Response containing redirect * - * @return HTTP_Request2_Response Response from a new location - * @throws HTTP_Request2_Exception + * @return HTTP_Request2_Response Response from a new location + * @throws HTTP_Request2_Exception */ protected function handleRedirect( HTTP_Request2 $request, HTTP_Request2_Response $response @@ -448,7 +458,7 @@ protected function handleRedirect( $redirect->setUrl($redirectUrl); if (303 == $response->getStatus() || (!$request->getConfig('strict_redirects') - && in_array($response->getStatus(), [301, 302])) + && in_array($response->getStatus(), [301, 302])) ) { $redirect->setMethod(HTTP_Request2::METHOD_GET); $redirect->setBody(''); @@ -475,8 +485,8 @@ protected function handleRedirect( * * @param HTTP_Request2_Response $response response to check * - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters + * @return boolean whether another request should be performed + * @throws HTTP_Request2_Exception in case of unsupported challenge parameters */ protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response) { @@ -540,8 +550,8 @@ protected function shouldUseServerDigestAuth(HTTP_Request2_Response $response) * * @param HTTP_Request2_Response $response response to check * - * @return boolean whether another request should be performed - * @throws HTTP_Request2_Exception in case of unsupported challenge parameters + * @return boolean whether another request should be performed + * @throws HTTP_Request2_Exception in case of unsupported challenge parameters */ protected function shouldUseProxyDigestAuth(HTTP_Request2_Response $response) { @@ -591,9 +601,9 @@ protected function shouldUseProxyDigestAuth(HTTP_Request2_Response $response) * * @param string $headerValue value of WWW-Authenticate or Proxy-Authenticate header * - * @return mixed associative array with challenge parameters, false if + * @return mixed associative array with challenge parameters, false if * no challenge is present in header value - * @throws HTTP_Request2_NotImplementedException in case of unsupported challenge parameters + * @throws HTTP_Request2_NotImplementedException in case of unsupported challenge parameters */ protected function parseDigestChallenge($headerValue) { @@ -641,10 +651,12 @@ protected function parseDigestChallenge($headerValue) /** * Parses [Proxy-]Authentication-Info header value and updates challenge * - * @param array &$challenge challenge to update + * @param array $challenge challenge to update * @param string $headerValue value of [Proxy-]Authentication-Info header * - * @todo validate server rspauth response + * @return void + * + * @todo validate server rspauth response */ protected function updateChallenge(&$challenge, $headerValue) { @@ -670,13 +682,13 @@ protected function updateChallenge(&$challenge, $headerValue) /** * Creates a value for [Proxy-]Authorization header when using digest authentication * - * @param string $user user name - * @param string $password password - * @param string $url request URL - * @param array &$challenge digest challenge parameters + * @param string $user user name + * @param string $password password + * @param string $url request URL + * @param array $challenge digest challenge parameters * - * @return string value of [Proxy-]Authorization request header - * @link http://tools.ietf.org/html/rfc2617#section-3.2.2 + * @return string value of [Proxy-]Authorization request header + * @link http://tools.ietf.org/html/rfc2617#section-3.2.2 */ protected function createDigestResponse($user, $password, $url, &$challenge) { @@ -718,11 +730,12 @@ protected function createDigestResponse($user, $password, $url, &$challenge) /** * Adds 'Authorization' header (if needed) to request headers array * - * @param array &$headers request headers + * @param array $headers request headers * @param string $requestHost request host (needed for digest authentication) * @param string $requestUrl request URL (needed for digest authentication) * - * @throws HTTP_Request2_NotImplementedException + * @return void + * @throws HTTP_Request2_NotImplementedException */ protected function addAuthorizationHeader(&$headers, $requestHost, $requestUrl) { @@ -764,17 +777,18 @@ protected function addAuthorizationHeader(&$headers, $requestHost, $requestUrl) /** * Adds 'Proxy-Authorization' header (if needed) to request headers array * - * @param array &$headers request headers + * @param array $headers request headers * @param string $requestUrl request URL (needed for digest authentication) * - * @throws HTTP_Request2_NotImplementedException + * @return void + * @throws HTTP_Request2_NotImplementedException */ protected function addProxyAuthorizationHeader(&$headers, $requestUrl) { if (!$this->request->getConfig('proxy_host') || !($user = $this->request->getConfig('proxy_user')) || (0 == strcasecmp('https', $this->request->getUrl()->getScheme()) - && HTTP_Request2::METHOD_CONNECT != $this->request->getMethod()) + && HTTP_Request2::METHOD_CONNECT != $this->request->getMethod()) ) { return; } @@ -812,8 +826,8 @@ protected function addProxyAuthorizationHeader(&$headers, $requestUrl) /** * Creates the string with the Request-Line and request headers * - * @return string - * @throws HTTP_Request2_Exception + * @return string + * @throws HTTP_Request2_Exception */ protected function prepareHeaders() { @@ -887,9 +901,11 @@ protected function prepareHeaders() * > 14.20) with the "100-continue" expectation if it does not intend * > to send a request body. * - * @param array &$headers Array of headers prepared for the request + * @param array $headers Array of headers prepared for the request * + * @return void * @throws HTTP_Request2_LogicException + * * @link http://pear.php.net/bugs/bug.php?id=19233 * @link http://tools.ietf.org/html/rfc2616#section-8.2.3 */ @@ -952,7 +968,8 @@ protected function updateExpectHeader(&$headers) /** * Sends the request body * - * @throws HTTP_Request2_MessageException + * @return void + * @throws HTTP_Request2_MessageException */ protected function writeBody() { @@ -994,8 +1011,8 @@ protected function writeBody() /** * Reads the remote server's response * - * @return HTTP_Request2_Response - * @throws HTTP_Request2_Exception + * @return HTTP_Request2_Response + * @throws HTTP_Request2_Exception */ protected function readResponse() { @@ -1032,7 +1049,7 @@ protected function readResponse() // No body possible in such responses if (HTTP_Request2::METHOD_HEAD == $this->request->getMethod() || (HTTP_Request2::METHOD_CONNECT == $this->request->getMethod() - && 200 <= $response->getStatus() && 300 > $response->getStatus()) + && 200 <= $response->getStatus() && 300 > $response->getStatus()) || in_array($response->getStatus(), [204, 304]) ) { return $response; @@ -1090,8 +1107,8 @@ protected function readResponse() * * @param int $bufferSize buffer size to use for reading * - * @return string - * @throws HTTP_Request2_MessageException + * @return string + * @throws HTTP_Request2_MessageException */ protected function readChunked($bufferSize) { diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/ConnectionException.php b/public_html/lists/admin/PEAR/HTTP/Request2/ConnectionException.php index fa82cbdd9..3e06c9396 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/ConnectionException.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/ConnectionException.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -28,7 +28,7 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @link http://pear.php.net/package/HTTP_Request2 */ class HTTP_Request2_ConnectionException extends HTTP_Request2_Exception diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/CookieJar.php b/public_html/lists/admin/PEAR/HTTP/Request2/CookieJar.php index 26a90bab2..297c11e4b 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/CookieJar.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/CookieJar.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -51,24 +51,28 @@ class HTTP_Request2_CookieJar implements Serializable /** * 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/ */ @@ -125,9 +129,9 @@ protected function now() * {@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 + * @return array Updated cookie array + * @throws HTTP_Request2_LogicException + * @throws HTTP_Request2_MessageException */ protected function checkAndUpdateFields(array $cookie, Net_URL2 $setter = null) { @@ -242,8 +246,8 @@ public function store(array $cookie, Net_URL2 $setter = null) * * @param HTTP_Request2_Response $response HTTP response message * @param Net_URL2 $setter original request URL, needed for - * setting default domain/path. If not given, - * effective URL from response will be used. + * setting default domain/path. If not given, + * effective URL from response will be used. * * @return bool whether all cookies were successfully stored * @throws HTTP_Request2_LogicException @@ -337,6 +341,8 @@ public function getAll() * Sets whether session cookies should be serialized when serializing the jar * * @param boolean $serialize serialize? + * + * @return void */ public function serializeSessionCookies($serialize) { @@ -347,6 +353,9 @@ public function serializeSessionCookies($serialize) * Sets whether invalid cookies should be silently ignored or cause an Exception * * @param boolean $ignore ignore? + * + * @return void + * * @link http://pear.php.net/bugs/bug.php?id=19937 * @link http://pear.php.net/bugs/bug.php?id=20401 */ @@ -374,7 +383,9 @@ public function ignoreInvalidCookies($ignore) * * @param boolean $useList use the list? * - * @link http://publicsuffix.org/learn/ + * @return void + * + * @link http://publicsuffix.org/learn/ */ public function usePublicSuffixList($useList) { @@ -386,9 +397,19 @@ public function usePublicSuffixList($useList) * * @return string * - * @see Serializable::serialize() + * @see Serializable::serialize() */ public function serialize() + { + return serialize($this->__serialize()); + } + + /** + * Returns an associative array of key/value pairs that represent the serialized form of the object + * + * @return array + */ + public function __serialize() { $cookies = $this->getAll(); if (!$this->serializeSession) { @@ -398,12 +419,12 @@ public function serialize() } } } - return serialize([ + return [ 'cookies' => $cookies, 'serializeSession' => $this->serializeSession, 'useList' => $this->useList, 'ignoreInvalid' => $this->ignoreInvalid - ]); + ]; } /** @@ -411,12 +432,23 @@ public function serialize() * * @param string $serialized string representation * - * @see Serializable::unserialize() + * @return void */ public function unserialize($serialized) { - $data = unserialize($serialized); - $now = $this->now(); + $this->__unserialize(unserialize($serialized)); + } + + /** + * Constructs the object from array serialized form + * + * @param array $data serialized form (as generated by {@see __serialize()} + * + * @return void + */ + public function __unserialize(array $data) + { + $now = $this->now(); $this->serializeSessionCookies($data['serializeSession']); $this->usePublicSuffixList($data['useList']); if (array_key_exists('ignoreInvalid', $data)) { @@ -446,7 +478,7 @@ public function unserialize($serialized) * @param string $requestHost request host * @param string $cookieDomain cookie domain * - * @return bool match success + * @return bool match success */ public function domainMatch($requestHost, $cookieDomain) { @@ -523,8 +555,7 @@ public static function getRegisteredDomain($domain) */ protected static function checkDomainsList(array $domainParts, $listNode) { - $sub = array_pop($domainParts); - $result = null; + $sub = array_pop($domainParts); if (!is_array($listNode) || is_null($sub) || array_key_exists('!' . $sub, $listNode) @@ -541,7 +572,7 @@ protected static function checkDomainsList(array $domainParts, $listNode) return $sub; } - return (strlen($result) > 0) ? ($result . '.' . $sub) : null; + return (strlen($result ?: '') > 0) ? ($result . '.' . $sub) : null; } } ?> \ No newline at end of file diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/Exception.php b/public_html/lists/admin/PEAR/HTTP/Request2/Exception.php index f74032d8b..018408cb7 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/Exception.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/Exception.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -30,34 +30,53 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @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 */ + /** + * An invalid argument was passed to a method + */ const INVALID_ARGUMENT = 1; - /** Some required value was not available */ + /** + * Some required value was not available + */ const MISSING_VALUE = 2; - /** Request cannot be processed due to errors in PHP configuration */ + /** + * Request cannot be processed due to errors in PHP configuration + */ const MISCONFIGURATION = 3; - /** Error reading the local file */ + /** + * Error reading the local file + */ const READ_ERROR = 4; - /** Server returned a response that does not conform to HTTP protocol */ + /** + * Server returned a response that does not conform to HTTP protocol + */ const MALFORMED_RESPONSE = 10; - /** Failure decoding Content-Encoding or Transfer-Encoding of response */ + /** + * Failure decoding Content-Encoding or Transfer-Encoding of response + */ const DECODE_ERROR = 20; - /** Operation timed out */ + /** + * Operation timed out + */ const TIMEOUT = 30; - /** Number of redirects exceeded 'max_redirects' configuration parameter */ + /** + * Number of redirects exceeded 'max_redirects' configuration parameter + */ const TOO_MANY_REDIRECTS = 40; - /** Redirect to a protocol other than http(s):// */ + /** + * Redirect to a protocol other than http(s):// + */ const NON_HTTP_REDIRECT = 50; /** * Native error code + * * @var int */ private $_nativeCode; diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/LogicException.php b/public_html/lists/admin/PEAR/HTTP/Request2/LogicException.php index 8f628f788..ba165aa70 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/LogicException.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/LogicException.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -32,7 +32,7 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @link http://pear.php.net/package/HTTP_Request2 */ class HTTP_Request2_LogicException extends HTTP_Request2_Exception diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/MessageException.php b/public_html/lists/admin/PEAR/HTTP/Request2/MessageException.php index 4133ef3eb..b92cf9439 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/MessageException.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/MessageException.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -27,7 +27,7 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @link http://pear.php.net/package/HTTP_Request2 */ class HTTP_Request2_MessageException extends HTTP_Request2_Exception diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/MultipartBody.php b/public_html/lists/admin/PEAR/HTTP/Request2/MultipartBody.php index e13618dde..eb28faf5b 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/MultipartBody.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/MultipartBody.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -31,7 +31,7 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @link http://pear.php.net/package/HTTP_Request2 * @link http://tools.ietf.org/html/rfc1867 */ @@ -39,31 +39,36 @@ class HTTP_Request2_MultipartBody { /** * MIME boundary - * @var string + * + * @var string */ private $_boundary; /** * Form parameters added via {@link HTTP_Request2::addPostParameter()} - * @var array + * + * @var array */ private $_params = []; /** * File uploads added via {@link HTTP_Request2::addUpload()} - * @var array + * + * @var array */ private $_uploads = []; /** * Header for parts with parameters - * @var string + * + * @var string */ private $_headerParam = "--%s\r\nContent-Disposition: form-data; name=\"%s\"\r\n\r\n"; /** * Header for parts with uploads - * @var string + * + * @var string */ private $_headerUpload = "--%s\r\nContent-Disposition: form-data; name=\"%s\"; filename=\"%s\"\r\nContent-Type: %s\r\n\r\n"; @@ -73,7 +78,7 @@ class HTTP_Request2_MultipartBody * First number is index of "current" part, second number is position within * "current" part * - * @var array + * @var array */ private $_pos = [0, 0]; @@ -110,7 +115,7 @@ public function __construct(array $params, array $uploads, $useBrackets = true) /** * Returns the length of the body to use in Content-Length header * - * @return integer + * @return integer */ public function getLength() { @@ -131,7 +136,7 @@ public function getLength() /** * Returns the boundary to use in Content-Type header * - * @return string + * @return string */ public function getBoundary() { @@ -146,8 +151,8 @@ public function getBoundary() * * @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 + * @return string Up to $length bytes of data, empty string if at end + * @throws HTTP_Request2_LogicException */ public function read($length) { @@ -211,6 +216,8 @@ public function read($length) * Sets the current position to the start of the body * * This allows reusing the same body in another request + * + * @return void */ public function rewind() { @@ -226,7 +233,7 @@ public function rewind() * Note that it reads all file uploads into memory so it is a good idea not * to use this method with large file uploads and rely on read() instead. * - * @return string + * @return string */ public function __toString() { @@ -243,7 +250,7 @@ public function __toString() * @param mixed $values item's values * @param bool $useBrackets whether to append [] to array variables' names * - * @return array array with the following items: array('item name', 'item value'); + * @return array array with the following items: array('item name', 'item value'); */ private static function _flattenArray($name, $values, $useBrackets) { diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/NotImplementedException.php b/public_html/lists/admin/PEAR/HTTP/Request2/NotImplementedException.php index eb0844326..289b85916 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/NotImplementedException.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/NotImplementedException.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -25,7 +25,7 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @link http://pear.php.net/package/HTTP_Request2 */ class HTTP_Request2_NotImplementedException extends HTTP_Request2_Exception diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/Observer/Log.php b/public_html/lists/admin/PEAR/HTTP/Request2/Observer/Log.php index 6797685ac..319107aa8 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/Observer/Log.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/Observer/Log.php @@ -14,7 +14,7 @@ * @package HTTP_Request2 * @author David Jean Louis * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -64,7 +64,7 @@ * @author David Jean Louis * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @link http://pear.php.net/package/HTTP_Request2 */ class HTTP_Request2_Observer_Log implements SplObserver @@ -119,6 +119,7 @@ public function __construct($target = 'php://output', array $events = []) // }}} // update() {{{ + #[ReturnTypeWillChange] /** * Called when the request notifies us of an event. * @@ -148,10 +149,12 @@ public function update(SplSubject $subject) $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() - )); + $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); diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/Observer/UncompressingDownload.php b/public_html/lists/admin/PEAR/HTTP/Request2/Observer/UncompressingDownload.php index 69b83c633..ef1b729a6 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/Observer/UncompressingDownload.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/Observer/UncompressingDownload.php @@ -14,7 +14,7 @@ * @package HTTP_Request2 * @author Delian Krustev * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -95,55 +95,63 @@ * @author Delian Krustev * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @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 + * '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 = ''; @@ -166,6 +174,7 @@ public function __construct($stream, $maxDownloadSize = null) } } + #[ReturnTypeWillChange] /** * Called when the request notifies us of an event. * @@ -185,7 +194,7 @@ public function update(SplSubject $request) case 'receivedHeaders': $this->_processingHeader = true; $this->_redirect = $event['data']->isRedirect(); - $this->_encoding = strtolower($event['data']->getHeader('content-encoding')); + $this->_encoding = strtolower($event['data']->getHeader('content-encoding') ?: ''); $this->_possibleHeader = ''; break; @@ -247,10 +256,12 @@ public function update(SplSubject $request) if ($this->_maxDownloadSize && ftell($this->_stream) - $this->_startPosition > $this->_maxDownloadSize ) { - throw new HTTP_Request2_MessageException(sprintf( - 'Body length limit (%d bytes) reached', - $this->_maxDownloadSize - )); + throw new HTTP_Request2_MessageException( + sprintf( + 'Body length limit (%d bytes) reached', + $this->_maxDownloadSize + ) + ); } break; diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/Response.php b/public_html/lists/admin/PEAR/HTTP/Request2/Response.php index 3ee3fe1c6..54a4ee143 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/Response.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/Response.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -47,7 +47,7 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @link http://pear.php.net/package/HTTP_Request2 * @link http://tools.ietf.org/html/rfc2616#section-6 */ @@ -55,12 +55,14 @@ class HTTP_Request2_Response { /** * HTTP protocol version (e.g. 1.0, 1.1) - * @var string + * + * @var string */ protected $version; /** * Status code + * * @var integer * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 */ @@ -68,6 +70,7 @@ class HTTP_Request2_Response /** * Reason phrase + * * @var string * @link http://tools.ietf.org/html/rfc2616#section-6.1.1 */ @@ -75,19 +78,22 @@ class HTTP_Request2_Response /** * Effective URL (may be different from original request URL in case of redirects) - * @var string + * + * @var string */ protected $effectiveUrl; /** * Associative array of response headers - * @var array + * + * @var array */ protected $headers = []; /** * Cookies set in the response - * @var array + * + * @var array */ protected $cookies = []; @@ -96,13 +102,14 @@ class HTTP_Request2_Response * * Used to handle the headers that span multiple lines * - * @var string + * @var string */ protected $lastHeader = null; /** * Response body - * @var string + * + * @var string */ protected $body = ''; @@ -112,7 +119,7 @@ class HTTP_Request2_Response * cURL provides the decoded body to the callback; if we are reading from * socket the body is still gzipped / deflated * - * @var bool + * @var bool */ protected $bodyEncoded; @@ -207,7 +214,7 @@ public static function getDefaultReasonPhrase($code = null) * @param bool $bodyEncoded Whether body is still encoded by Content-Encoding * @param string $effectiveUrl Effective URL of the response * - * @throws HTTP_Request2_MessageException if status line is invalid according to spec + * @throws HTTP_Request2_MessageException if status line is invalid according to spec */ public function __construct($statusLine, $bodyEncoded = true, $effectiveUrl = null) { @@ -233,6 +240,8 @@ public function __construct($statusLine, $bodyEncoded = true, $effectiveUrl = nu * empty string in the end. * * @param string $headerLine Line from HTTP response + * + * @return void */ public function parseHeaderLine($headerLine) { @@ -285,7 +294,9 @@ public function parseHeaderLine($headerLine) * * @param string $cookieString value of Set-Cookie header * - * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html + * @return void + * + * @link http://web.archive.org/web/20080331104521/http://cgi.netscape.com/newsref/std/cookie_spec.html */ protected function parseCookie($cookieString) { @@ -335,6 +346,8 @@ protected function parseCookie($cookieString) * Appends a string to the response body * * @param string $bodyChunk part of response body + * + * @return void */ public function appendBody($bodyChunk) { @@ -357,7 +370,7 @@ public function getEffectiveUrl() /** * Returns the status code * - * @return integer + * @return integer */ public function getStatus() { @@ -367,7 +380,7 @@ public function getStatus() /** * Returns the reason phrase * - * @return string + * @return string */ public function getReasonPhrase() { @@ -377,7 +390,7 @@ public function getReasonPhrase() /** * Whether response is a redirect that can be automatically handled by HTTP_Request2 * - * @return bool + * @return bool */ public function isRedirect() { @@ -390,7 +403,7 @@ public function isRedirect() * * @param string $headerName Name of header to return * - * @return string|array Value of $headerName header (null if header is + * @return string|array Value of $headerName header (null if header is * not present), array of all response headers if * $headerName is null */ @@ -407,7 +420,7 @@ public function getHeader($headerName = null) /** * Returns cookies set in response * - * @return array + * @return array */ public function getCookies() { @@ -417,13 +430,13 @@ public function getCookies() /** * Returns the body of the response * - * @return string - * @throws HTTP_Request2_Exception if body cannot be decoded + * @return string + * @throws HTTP_Request2_Exception if body cannot be decoded */ public function getBody() { if (0 == strlen($this->body) || !$this->bodyEncoded - || !in_array(strtolower($this->getHeader('content-encoding')), ['gzip', 'deflate']) + || !in_array(strtolower($this->getHeader('content-encoding') ?: ''), ['gzip', 'deflate']) ) { return $this->body; @@ -452,7 +465,7 @@ public function getBody() /** * Get the HTTP version of the response * - * @return string + * @return string */ public function getVersion() { @@ -602,10 +615,10 @@ public static function parseGzipHeader($data, $dataComplete = false) * * @param string $data gzip-encoded data * - * @return string decoded data - * @throws HTTP_Request2_LogicException - * @throws HTTP_Request2_MessageException - * @link http://tools.ietf.org/html/rfc1952 + * @return string decoded data + * @throws HTTP_Request2_LogicException + * @throws HTTP_Request2_MessageException + * @link http://tools.ietf.org/html/rfc1952 */ public static function decodeGzip($data) { @@ -657,8 +670,8 @@ public static function decodeGzip($data) * * @param string $data deflate-encoded data * - * @return string decoded data - * @throws HTTP_Request2_LogicException + * @return string decoded data + * @throws HTTP_Request2_LogicException */ public static function decodeDeflate($data) { diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/SOCKS5.php b/public_html/lists/admin/PEAR/HTTP/Request2/SOCKS5.php index a7d7a77ee..ac519b554 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/SOCKS5.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/SOCKS5.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -28,7 +28,7 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @link http://pear.php.net/package/HTTP_Request2 * @link http://pear.php.net/bugs/bug.php?id=19332 * @link http://tools.ietf.org/html/rfc1928 @@ -85,9 +85,10 @@ public function __construct( * @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 + * @link http://tools.ietf.org/html/rfc1929 */ protected function performAuthentication($username, $password) { @@ -109,6 +110,7 @@ protected function performAuthentication($username, $password) * @param string $remoteHost Remote host * @param int $remotePort Remote port * + * @return void * @throws HTTP_Request2_ConnectionException * @throws HTTP_Request2_MessageException */ diff --git a/public_html/lists/admin/PEAR/HTTP/Request2/SocketWrapper.php b/public_html/lists/admin/PEAR/HTTP/Request2/SocketWrapper.php index 83e401423..a55bd4303 100644 --- a/public_html/lists/admin/PEAR/HTTP/Request2/SocketWrapper.php +++ b/public_html/lists/admin/PEAR/HTTP/Request2/SocketWrapper.php @@ -13,7 +13,7 @@ * @category HTTP * @package HTTP_Request2 * @author Alexey Borzov - * @copyright 2008-2020 Alexey Borzov + * @copyright 2008-2022 Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License * @link http://pear.php.net/package/HTTP_Request2 */ @@ -31,7 +31,7 @@ * @package HTTP_Request2 * @author Alexey Borzov * @license http://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License - * @version Release: 2.4.2 + * @version Release: 2.5.1 * @link http://pear.php.net/package/HTTP_Request2 * @link http://pear.php.net/bugs/bug.php?id=19332 * @link http://tools.ietf.org/html/rfc1928 @@ -40,24 +40,28 @@ 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 */ protected $deadline; /** * Global timeout value, mostly for exception messages + * * @var integer */ protected $timeout; @@ -82,6 +86,10 @@ public function __construct($address, $timeout, array $contextOptions = []) $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 @@ -97,8 +105,7 @@ public function __construct($address, $timeout, array $contextOptions = []) . 'DHE-RSA-AES128-GCM-SHA256:' . 'DHE-RSA-AES256-GCM-SHA384', 'disable_compression' => true, - 'crypto_method' => STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT - | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT + 'crypto_method' => $cryptoMethod ]; } $context = stream_context_create(); @@ -147,8 +154,8 @@ public function __destruct() * * @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 + * @return string|false Data read from socket by fread() + * @throws HTTP_Request2_MessageException In case of timeout */ public function read($length) { @@ -182,8 +189,8 @@ public function read($length) * @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 + * @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) { @@ -228,23 +235,33 @@ public function readLine($bufferSize, $localTimeout = null) public function write($data) { $totalWritten = 0; - while (strlen($data)) { + while (strlen($data) && !$this->eof()) { $written = 0; + $error = null; $timeouts = $this->_getTimeoutsForStreamSelect(); - $r = []; + $r = null; $w = [$this->socket]; - $e = []; + $e = null; if (stream_select($r, $w, $e, $timeouts[0], $timeouts[1])) { - // Notice: fwrite(): send of #### bytes failed with errno=10035 - // A non-blocking socket operation could not be completed immediately. - $written = @fwrite($this->socket, $data); + set_error_handler( + static function ($errNo, $errStr) use (&$error) { + if (0 !== (E_NOTICE | E_WARNING) & $errNo) { + $error = $errStr; + } + } + ); + $written = fwrite($this->socket, $data); + restore_error_handler(); } $this->checkTimeout(); - // http://www.php.net/manual/en/function.fwrite.php#96951 - if (0 === (int)$written) { - throw new HTTP_Request2_MessageException('Error writing request'); + // php_sockop_write() defined in /main/streams/xp_socket.c may return zero written bytes for non-blocking + // sockets in case of transient errors. These writes will not have notices raised and should be retried + if (false === $written || 0 === $written && null !== $error) { + throw new HTTP_Request2_MessageException( + 'Error writing request' . (null === $error ? '' : ': ' . $error) + ); } $data = substr($data, $written); $totalWritten += $written; @@ -271,8 +288,10 @@ public function eof() * * @param float|null $deadline Exception will be thrown if request continues * past this time - * @param int $timeout Original request timeout value, to use in + * @param int $timeout Original request timeout value, to use in * Exception message + * + * @return void */ public function setDeadline($deadline, $timeout) { @@ -286,12 +305,15 @@ public function setDeadline($deadline, $timeout) /** * Turns on encryption on a socket * + * @return void * @throws HTTP_Request2_ConnectionException */ public function enableCrypto() { - $cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT - | STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; + $cryptoMethod = STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; + if (defined('STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT')) { + $cryptoMethod |= STREAM_CRYPTO_METHOD_TLSv1_3_CLIENT; + } try { stream_set_blocking($this->socket, true); @@ -308,6 +330,7 @@ public function enableCrypto() /** * Throws an Exception if stream timed out * + * @return void * @throws HTTP_Request2_MessageException */ protected function checkTimeout()