Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Fixed the zero value in ContentLength
Browse files Browse the repository at this point in the history
  • Loading branch information
ezimuel committed Aug 8, 2016
1 parent e9fb717 commit b5cc5ba
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Header/ContentLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static function fromString($headerLine)

public function __construct($value = null)
{
if ($value) {
if (null !== $value) {
HeaderValue::assertValid($value);
$this->value = $value;
}
Expand Down
7 changes: 7 additions & 0 deletions test/Header/ContentLengthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,11 @@ public function testPreventsCRLFAttackViaConstructor()
$this->setExpectedException('Zend\Http\Header\Exception\InvalidArgumentException');
$header = new ContentLength("Content-Length: xxx\r\n\r\nevilContent");
}

public function testZeroValue()
{
$contentLengthHeader = new ContentLength(0);
$this->assertEquals(0, $contentLengthHeader->getFieldValue());
$this->assertEquals('Content-Length: 0', $contentLengthHeader->toString());
}
}

0 comments on commit b5cc5ba

Please sign in to comment.