diff --git a/www/pear-HTTP_Request2/Makefile b/www/pear-HTTP_Request2/Makefile index 9f773de12c87..f344a9db4727 100644 --- a/www/pear-HTTP_Request2/Makefile +++ b/www/pear-HTTP_Request2/Makefile @@ -1,28 +1,32 @@ # Created by: Wen Heping PORTNAME= HTTP_Request2 -PORTVERSION= 2.4.2 +DISTVERSION= 2.4.2 +PORTREVISION= 1 PORTEPOCH= 1 CATEGORIES= www pear MAINTAINER= sunpoet@FreeBSD.org COMMENT= PEAR classes providing an easy way to perform HTTP requests +LICENSE= BSD3CLAUSE +LICENSE_FILE= ${WRKSRC}/docs/LICENSE + BUILD_DEPENDS= ${PEARDIR}/Net/URL2.php:net/pear-Net_URL2@${PHP_FLAVOR} RUN_DEPENDS= ${PEARDIR}/Net/URL2.php:net/pear-Net_URL2@${PHP_FLAVOR} +USES= pear + OPTIONS_DEFINE= CURL FILEINFO ZLIB CURL_DESC= PHP CURL extension support FILEINFO_DESC= PHP FILEINFO extension support ZLIB_DESC= PECL ZLIB support -USES= pear - CURL_USES= php CURL_USE= PHP=curl FILEINFO_USES= php FILEINFO_USE= PHP=fileinfo ZLIB_USES= php ZLIB_USE= PHP=zlib .include diff --git a/www/pear-HTTP_Request2/files/patch-HTTP_Request2_SocketWrapper.php b/www/pear-HTTP_Request2/files/patch-HTTP_Request2_SocketWrapper.php new file mode 100644 index 000000000000..772670d4eb23 --- /dev/null +++ b/www/pear-HTTP_Request2/files/patch-HTTP_Request2_SocketWrapper.php @@ -0,0 +1,48 @@ +From 63e6f932ab4004f0c09a080d370861d0323b6d33 Mon Sep 17 00:00:00 2001 +From: Alexey Borzov +Date: Fri, 25 Jun 2021 15:05:27 +0300 +Subject: [PATCH] Attempt to fix #23 or at least be more verbose + +--- HTTP/Request2/SocketWrapper.php.orig 2020-09-24 22:12:37 UTC ++++ HTTP/Request2/SocketWrapper.php +@@ -228,23 +228,31 @@ class HTTP_Request2_SocketWrapper + 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;