Skip to content

Commit

Permalink
ZendClient breaks when receiving a HTTP/2 response
Browse files Browse the repository at this point in the history
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.
```
  • Loading branch information
rjocoleman committed Dec 4, 2019
1 parent 33e45b2 commit 6605fdb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/Zend/Http/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 6605fdb

Please sign in to comment.