diff --git a/src/Header/AbstractAccept.php b/src/Header/AbstractAccept.php index 4ac2a8da2b..92e835d93e 100644 --- a/src/Header/AbstractAccept.php +++ b/src/Header/AbstractAccept.php @@ -56,18 +56,22 @@ abstract class AbstractAccept implements HeaderInterface /** + * Parse a full header line or just the field value part. * * @param string $headerLine */ public function parseHeaderLine($headerLine) { - $fieldName = $this->getFieldName(); - $pos = strlen($fieldName) + 2; - if (strtolower(substr($headerLine, 0, $pos)) == strtolower($fieldName) . ': ') { - $headerLine = substr($headerLine, $pos); + if (strpos($headerLine, ':') !== false) { + list($name, $value) = GenericHeader::splitHeaderLine($headerLine); + if (strtolower($name) !== strtolower($this->getFieldName())) { + $value = $headerLine; // This is just for preserve the BC. + } + } else { + $value = $headerLine; } - foreach ($this->getFieldValuePartsFromHeaderLine($headerLine) as $value) { + foreach ($this->getFieldValuePartsFromHeaderLine($value) as $value) { $this->addFieldValuePartToQueue($value); } } diff --git a/test/Header/AcceptTest.php b/test/Header/AcceptTest.php index 45a7096a86..ca6885caca 100644 --- a/test/Header/AcceptTest.php +++ b/test/Header/AcceptTest.php @@ -40,6 +40,12 @@ public function testAcceptGetFieldValueReturnsProperValue() $this->assertEquals('xxx', $acceptHeader->getFieldValue()); } + public function testAcceptGetFieldValueReturnsProperValueWithAHeaderWithoutSpaces() + { + $acceptHeader = Accept::fromString('Accept:xxx'); + $this->assertEquals('xxx', $acceptHeader->getFieldValue()); + } + public function testAcceptToStringReturnsHeaderFormattedString() { $acceptHeader = new Accept();