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

Commit d66ecc0

Browse files
committed
Merge pull request #87 from ezimuel/fix/content-length-zero
Fixed the zero value in ContentLength
2 parents e9fb717 + b5cc5ba commit d66ecc0

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/Header/ContentLength.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static function fromString($headerLine)
4040

4141
public function __construct($value = null)
4242
{
43-
if ($value) {
43+
if (null !== $value) {
4444
HeaderValue::assertValid($value);
4545
$this->value = $value;
4646
}

test/Header/ContentLengthTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,11 @@ public function testPreventsCRLFAttackViaConstructor()
6565
$this->setExpectedException('Zend\Http\Header\Exception\InvalidArgumentException');
6666
$header = new ContentLength("Content-Length: xxx\r\n\r\nevilContent");
6767
}
68+
69+
public function testZeroValue()
70+
{
71+
$contentLengthHeader = new ContentLength(0);
72+
$this->assertEquals(0, $contentLengthHeader->getFieldValue());
73+
$this->assertEquals('Content-Length: 0', $contentLengthHeader->toString());
74+
}
6875
}

0 commit comments

Comments
 (0)