Skip to content

Commit 22d2725

Browse files
committed
🚿
1 parent 856ffb2 commit 22d2725

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/MessageUtil.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ protected static function call_decompress_func(string $func, string $data):strin
139139
public static function setContentLengthHeader(MessageInterface $message):MessageInterface{
140140
$bodySize = $message->getBody()->getSize();
141141

142-
if(!$message->hasHeader('Content-Length') && $bodySize !== null){
142+
if(!$message->hasHeader('Content-Length') && $bodySize !== null && $bodySize > 0){
143143
$message = $message->withHeader('Content-Length', (string)$bodySize);
144144
}
145145

tests/HeaderUtilTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ public static function headerDataProvider():array{
3333
'arrayvalue' => [['foo' => ['bar', 'baz']], ['Foo' => 'bar, baz']],
3434
'invalid: 2' => [[2 => 2], []],
3535
'invalid: what' => [['what'], []],
36+
'empty value' => [['empty-value' => ''], ['Empty-Value' => '']],
37+
'null value' => [['null-value' => null], ['Null-Value' => '']],
3638
];
3739
}
3840

0 commit comments

Comments
 (0)