Skip to content

Commit 932a3ca

Browse files
Nyholmsagikazarmark
authored andcommitted
Make sure we validate server version according to rfc2145 (#35)
1 parent 1016399 commit 932a3ca

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/HttpBaseTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,8 @@ protected function assertResponse($response, array $options = [])
221221

222222
$options = array_merge($this->defaultOptions, $options);
223223

224-
$this->assertSame($options['protocolVersion'], $response->getProtocolVersion());
224+
// The response version may be greater or equal to the request version. See https://tools.ietf.org/html/rfc2145#section-2.3
225+
$this->assertTrue(substr($options['protocolVersion'], 0, 1) === substr($response->getProtocolVersion(), 0, 1) && 1 !== version_compare($options['protocolVersion'], $response->getProtocolVersion()));
225226
$this->assertSame($options['statusCode'], $response->getStatusCode());
226227
$this->assertSame($options['reasonPhrase'], $response->getReasonPhrase());
227228

@@ -253,7 +254,8 @@ protected function assertRequest(
253254
) {
254255
$request = $this->getRequest();
255256

256-
$this->assertSame($protocolVersion, substr($request['SERVER']['SERVER_PROTOCOL'], 5));
257+
$actualProtocolVersion = substr($request['SERVER']['SERVER_PROTOCOL'], 5);
258+
$this->assertTrue(substr($protocolVersion, 0, 1) === substr($actualProtocolVersion, 0, 1) && 1 !== version_compare($protocolVersion, $actualProtocolVersion));
257259
$this->assertSame($method, $request['SERVER']['REQUEST_METHOD']);
258260

259261
$defaultHeaders = [

0 commit comments

Comments
 (0)