Skip to content

Commit 7e7d0d9

Browse files
committed
- adds HTTP/2 protocol check
1 parent 84f31ad commit 7e7d0d9

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

MessageTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public function getProtocolVersion(): string
2626

2727
public function withProtocolVersion($version): static
2828
{
29-
if (false === \in_array($version, ['1.0', '1.1'], true)) {
29+
if (false === \in_array($version, ['1.0', '1.1', '2'], true)) {
3030
throw new \InvalidArgumentException('Unsupported HTTP protocol version ' . $version);
3131
}
3232
$instance = clone $this;

Tests/MessageTraitTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ class MessageTraitTest extends TestCase
1414
public function test_should_deal_with_unsupported_protocol()
1515
{
1616
$this->expectException(\InvalidArgumentException::class);
17-
$this->expectExceptionMessage('Unsupported HTTP protocol version 2');
18-
(new TestMessage)->withProtocolVersion('2');
17+
$this->expectExceptionMessage('Unsupported HTTP protocol version 3');
18+
(new TestMessage)->withProtocolVersion('3');
1919
}
2020

2121
public function test_should_set_supported_protocol_versions()
2222
{
2323
$this->assertSame('1.0', $this->SUT->withProtocolVersion('1.0')->getProtocolVersion());
2424
$this->assertSame('1.1', $this->SUT->withProtocolVersion('1.1')->getProtocolVersion());
25+
$this->assertSame('2', $this->SUT->withProtocolVersion('2')->getProtocolVersion());
2526
}
2627

2728
public function test_should_always_return_instance_of_stream()

0 commit comments

Comments
 (0)