Skip to content

Commit

Permalink
Merge pull request #317 from guzzle/header-values-with-keys
Browse files Browse the repository at this point in the history
ignore array keys in header values for correct merging
  • Loading branch information
Tobion committed Feb 4, 2020
2 parents ce6ae06 + e5c1dea commit e193ff3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/MessageTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ private function trimHeaderValues(array $values)
}

return trim((string) $value, " \t");
}, $values);
}, array_values($values));
}

private function assertHeader($header)
Expand Down
9 changes: 9 additions & 0 deletions tests/ResponseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,15 @@ public function testHeaderValuesAreTrimmed()
}
}

public function testWithAddedHeaderArrayValueAndKeys()
{
$message = (new Response())->withAddedHeader('list', ['foo' => 'one']);
$message = $message->withAddedHeader('list', ['foo' => 'two', 'bar' => 'three']);

$headerLine = $message->getHeaderLine('list');
$this->assertSame('one, two, three', $headerLine);
}

/**
* @dataProvider nonIntegerStatusCodeProvider
* @param mixed $invalidValues
Expand Down

0 comments on commit e193ff3

Please sign in to comment.