Skip to content

Commit d22ba20

Browse files
committed
feat: Remove default content-length header from MultipartStreamBuilder class
1 parent ed56da2 commit d22ba20

File tree

2 files changed

+2
-9
lines changed

2 files changed

+2
-9
lines changed

src/MultipartStreamBuilder.php

-7
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,6 @@ private function prepareHeaders($name, StreamInterface $stream, $filename, array
185185
}
186186
}
187187

188-
// Set a default content-length header if one was not provided
189-
if (!$this->hasHeader($headers, 'content-length')) {
190-
if ($length = $stream->getSize()) {
191-
$headers['Content-Length'] = (string) $length;
192-
}
193-
}
194-
195188
// Set a default Content-Type if one was not provided
196189
if (!$this->hasHeader($headers, 'content-type') && $hasFilename) {
197190
if ($type = $this->getMimetypeHelper()->getMimetypeFromFilename($filename)) {

tests/FunctionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,13 @@ public function testHeaders()
8888
$this->assertTrue(false === strpos($multipartStream, 'Content-Disposition:'));
8989
}
9090

91-
public function testContentLength()
91+
public function testShouldNotContainContentLength()
9292
{
9393
$builder = new MultipartStreamBuilder();
9494
$builder->addResource('foobar', 'stream contents');
9595

9696
$multipartStream = (string) $builder->build();
97-
$this->assertTrue(false !== strpos($multipartStream, 'Content-Length: 15'));
97+
$this->assertTrue(false === strpos($multipartStream, 'Content-Length: 15'));
9898
}
9999

100100
public function testFormName()

0 commit comments

Comments
 (0)