Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Jan 8, 2020. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions tests/ZendTest/Http/HeadersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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');
Expand Down