Skip to content

Commit 1e65616

Browse files
rjocolemanFlyingmana
authored andcommitted
ZendClient breaks when receiving a HTTP/2 response (#867)
Ref magento/zf1#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. ```
1 parent 33e45b2 commit 1e65616

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

lib/Zend/Http/Response.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function __construct($code, array $headers, $body = null, $version = '1.1
182182
$this->body = $body;
183183

184184
// Set the HTTP version
185-
if (! preg_match('|^\d\.\d$|', $version)) {
185+
if (! preg_match('|^\d+(?:\.\d+)?$|', $version)) {
186186
#require_once 'Zend/Http/Exception.php';
187187
throw new Zend_Http_Exception("Invalid HTTP response version: $version");
188188
}
@@ -514,7 +514,7 @@ public static function extractHeaders($response_str)
514514
$last_header = null;
515515

516516
foreach($lines as $index => $line) {
517-
if ($index === 0 && preg_match('#^HTTP/\d+(?:\.\d+) [1-5]\d+#', $line)) {
517+
if ($index === 0 && preg_match('#^HTTP/\d+(?:\.\d+)? [1-5]\d+#', $line)) {
518518
// Status line; ignore
519519
continue;
520520
}

0 commit comments

Comments
 (0)