From 1e65616b7aa6c684b8bf7edded44cfdd05c77fef Mon Sep 17 00:00:00 2001 From: Robert Coleman Date: Mon, 9 Dec 2019 23:21:20 +1300 Subject: [PATCH] ZendClient breaks when receiving a HTTP/2 response (#867) Ref https://github.com/magento/zf1/pull/23 ``` The issue is caused by the fact that the response result is checked by a regular expression that expects the Protocol version in the d.d format (for example, 1.0 or 1.1). For HTTP 2.0, the header returns a value in the format "HTTP/2 200 OK" without the decimal part. This results in an error. ``` --- lib/Zend/Http/Response.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Zend/Http/Response.php b/lib/Zend/Http/Response.php index af0fa836fa9..0caf82741a8 100644 --- a/lib/Zend/Http/Response.php +++ b/lib/Zend/Http/Response.php @@ -182,7 +182,7 @@ public function __construct($code, array $headers, $body = null, $version = '1.1 $this->body = $body; // Set the HTTP version - if (! preg_match('|^\d\.\d$|', $version)) { + if (! preg_match('|^\d+(?:\.\d+)?$|', $version)) { #require_once 'Zend/Http/Exception.php'; throw new Zend_Http_Exception("Invalid HTTP response version: $version"); } @@ -514,7 +514,7 @@ public static function extractHeaders($response_str) $last_header = null; foreach($lines as $index => $line) { - if ($index === 0 && preg_match('#^HTTP/\d+(?:\.\d+) [1-5]\d+#', $line)) { + if ($index === 0 && preg_match('#^HTTP/\d+(?:\.\d+)? [1-5]\d+#', $line)) { // Status line; ignore continue; }