diff --git a/CHANGELOG.md b/CHANGELOG.md index 6776f57..ab7a8ce 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## Unreleased + +### Fixed + +- #41: Response builder broke header value + + ## 1.2.0 - 2016-03-29 ### Added diff --git a/spec/Builder/ResponseBuilderSpec.php b/spec/Builder/ResponseBuilderSpec.php index 606884a..c4cc81e 100644 --- a/spec/Builder/ResponseBuilderSpec.php +++ b/spec/Builder/ResponseBuilderSpec.php @@ -23,13 +23,16 @@ function it_reads_headers_from_array(ResponseInterface $response) $this->setHeadersFromArray(['HTTP/1.1 200 OK', 'Content-type: text/html']); } - function it_reads_headers_from_string(ResponseInterface $response) + /** + * @link https://github.com/php-http/message/issues/41 + */ + function it_splits_headers_correctly(ResponseInterface $response) { $response->withStatus(200, 'OK')->willReturn($response); $response->withProtocolVersion('1.1')->willReturn($response); $response->hasHeader('Content-type')->willReturn(false); - $response->withHeader('Content-type', 'text/html')->willReturn($response); + $response->withHeader('Content-type', 'application/xml+atom')->willReturn($response); $this->beConstructedWith($response); - $this->setHeadersFromString("HTTP/1.1 200 OK\r\nContent-type: text/html\r\n"); + $this->setHeadersFromString("HTTP/1.1 200 OK\r\nContent-type: application/xml+atom\r\n"); } } diff --git a/src/Builder/ResponseBuilder.php b/src/Builder/ResponseBuilder.php index 0a198f4..e6933a0 100644 --- a/src/Builder/ResponseBuilder.php +++ b/src/Builder/ResponseBuilder.php @@ -135,8 +135,8 @@ public function addHeader($headerLine) sprintf('"%s" is not a valid HTTP header line', $headerLine) ); } - $name = trim(urldecode($parts[0])); - $value = trim(urldecode($parts[1])); + $name = trim($parts[0]); + $value = trim($parts[1]); if ($this->response->hasHeader($name)) { $this->response = $this->response->withAddedHeader($name, $value); } else {