aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRenato Botelho <garga@FreeBSD.org>2021-07-02 13:47:09 +0000
committerRenato Botelho <garga@FreeBSD.org>2021-07-12 09:59:28 +0000
commit9aaa558bcc2753749a9a4abbf7cc21448d1c1b0c (patch)
tree623008c5ab499912ba425296f9a6cc1794d96560
parent47514c9ad2e937cc8187563b6ebf74fadbea0844 (diff)
downloadports-9aaa558bcc2753749a9a4abbf7cc21448d1c1b0c.tar.gz
ports-9aaa558bcc2753749a9a4abbf7cc21448d1c1b0c.zip
www/pear-HTTP_Request2: Import fix from upstream
pfSense users reported a communication error on code that uses HTTP_Request2 after we moved to most recent version. After reporting the issue to upstream they came up with a fix that confirmed working. This change adds upstream fix and while here, I also changed USES order to make portlint happy and added LICENSE. [1] https://redmine.pfsense.org/issues/12048 Obtained from: pfSense Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31000
-rw-r--r--www/pear-HTTP_Request2/Makefile10
-rw-r--r--www/pear-HTTP_Request2/files/patch-HTTP_Request2_SocketWrapper.php48
2 files changed, 55 insertions, 3 deletions
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,23 +1,27 @@
# Created by: Wen Heping <wenheping@gmail.com>
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
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 <avb@php.net>
+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;