Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Zend\Http: Unit tests for multi-line headers #5916

Merged
merged 1 commit into from

2 participants

@ralphschindler
Collaborator

As per http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html and the original issue #5608

Notes:

@ralphschindler ralphschindler added this to the 2.2.6 milestone
@weierophinney weierophinney self-assigned this
@weierophinney weierophinney merged commit 390c9d8 into zendframework:master
@weierophinney weierophinney referenced this pull request from a commit
Commit has since been removed from the repository and is no longer available.
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-http
@weierophinney weierophinney Merge pull request zendframework/zf2#5916 from ralphschindler/hotfix/…
…http-multiline-headers

Zend\Http: Unit tests for multi-line headers
4812ec5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 2 deletions.
  1. +15 −2 tests/ZendTest/Http/HeadersTest.php
View
17 tests/ZendTest/Http/HeadersTest.php
@@ -57,7 +57,8 @@ public function testHeadersFromStringFactoryCreatesSingleObjectWithContinuationL
$header = $headers->get('fake');
$this->assertInstanceOf('Zend\Http\Header\GenericHeader', $header);
$this->assertEquals('Fake', $header->getFieldName());
- $this->assertEquals('foo-bar,blah-blah', $header->getFieldValue());
+ // any leading space MAY be replaced by a single space @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
+ $this->assertEquals('foo-bar, blah-blah', $header->getFieldValue());
}
public function testHeadersFromStringFactoryCreatesSingleObjectWithContinuationLineAndLeadingWhitespaces()
@@ -68,7 +69,8 @@ public function testHeadersFromStringFactoryCreatesSingleObjectWithContinuationL
$header = $headers->get('fake');
$this->assertInstanceOf('Zend\Http\Header\GenericHeader', $header);
$this->assertEquals('Fake', $header->getFieldName());
- $this->assertEquals('foo-bar,blah-blah', $header->getFieldValue());
+ // any leading space MAY be replaced by a single space @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html
+ $this->assertEquals('foo-bar, blah-blah', $header->getFieldValue());
}
public function testHeadersFromStringFactoryCreatesSingleObjectWithHeaderBreakLine()
@@ -93,6 +95,17 @@ public function testHeadersFromStringFactoryCreatesSingleObjectWithHeaderBreakLi
$this->assertEquals('foo-bar', $header->getFieldValue());
}
+ public function testHeadersFromStringFactoryRespectsSpecAllowedMultiLineHeaders()
+ {
+ $headers = Headers::fromString("Foo: foo-bar\r\nX-Another: another\r\n X-Actually-A-Continuation:ofSomeKindOfValue\r\nX-Another: another\r\n");
+ $this->assertEquals(3, $headers->count());
+
+ // check continued header
+ $header = $headers->get('X-Another');
+ $this->assertEquals('X-Another', $header->getFieldName());
+ $this->assertEquals('another X-Actually-A-Continuation:ofSomeKindOfValue', $header->getFieldValue());
+ }
+
public function testHeadersFromStringFactoryThrowsExceptionOnMalformedHeaderLine()
{
$this->setExpectedException('Zend\Http\Exception\RuntimeException', 'does not match');
Something went wrong with that request. Please try again.