Skip to content
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
@av3

Description

@av3

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions