This repository was archived by the owner on Jan 30, 2020. It is now read-only.
This repository was archived by the owner on Jan 30, 2020. It is now read-only.
parseStatusLine throws exception for HTTP/2 Response #172
Closed
Description
I want to write a small function to test, if a specific Host supports HTTP/2 - using zend-http and the CURL adapter with the CURL_HTTP_VERSION_2_0 option. But this ends in an exception:
Zend \ Http \ Exception \ InvalidArgumentException
A valid response status line was not found in the provided string
It seems that the regex within parseStatusLine (https://github.com/zendframework/zend-http/blob/master/src/Response.php#L252) doesn't match with the HTTP/2 response.
Code to reproduce the issue (incomplete)
$client = new \Zend\Http\Client\Client();
$options = [
'adapter' => \Zend\Http\Client\Adapter\Curl::class,
'curloptions' => [
// ...
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_2_0,
],
];
$client->setOptions($options);
// ...
$response = $client->send();
Test case for this:
public function testResponseFactoryFromStringCreatesValidHTTP2Response()
{
$string = 'HTTP/2.0 200 OK' . "\r\n\r\n" . 'Foo Bar';
$response = \Zend\Http\Response::fromString($string);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('Foo Bar', $response->getContent());
}
Metadata
Metadata
Assignees
Labels
No labels