Skip to content

Commit

Permalink
Release 1.8.5 (guzzle#491)
Browse files Browse the repository at this point in the history
  • Loading branch information
GrahamCampbell authored and TimWolla committed Mar 21, 2022
1 parent ff7be9f commit 986596d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/MessageTrait.php
Expand Up @@ -262,7 +262,7 @@ private function assertValue($value)
// Clients must not send a request with line folding and a server sending folded headers is
// likely very rare. Line folding is a fairly obscure feature of HTTP/1.1 and thus not accepting
// folding is not likely to break any legitimate use case.
if (! preg_match('/^(?:[\x21-\x7E\x80-\xFF](?:[\x20\x09]+[\x21-\x7E\x80-\xFF])?)*$/', $value)) {
if (! preg_match('/^[\x20\x09\x21-\x7E\x80-\xFF]*$/', $value)) {
throw new \InvalidArgumentException(sprintf('"%s" is not valid header value', $value));
}
}
Expand Down
11 changes: 11 additions & 0 deletions tests/RequestTest.php
Expand Up @@ -175,6 +175,17 @@ public function testHostIsAddedFirst()
], $r->getHeaders());
}

public function testHeaderValueWithWhitespace()
{
$r = new Request('GET', 'https://example.com/', [
'User-Agent' => 'Linux f0f489981e90 5.10.104-linuxkit 1 SMP Wed Mar 9 19:05:23 UTC 2022 x86_64'
]);
self::assertSame([
'Host' => ['example.com'],
'User-Agent' => ['Linux f0f489981e90 5.10.104-linuxkit 1 SMP Wed Mar 9 19:05:23 UTC 2022 x86_64']
], $r->getHeaders());
}

public function testCanGetHeaderAsCsv()
{
$r = new Request('GET', 'http://foo.com/baz?bar=bam', [
Expand Down

0 comments on commit 986596d

Please sign in to comment.