Skip to content
Open
Show file tree
Hide file tree
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
8 changes: 0 additions & 8 deletions src/MultipartStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,6 @@ private function createElement(string $name, StreamInterface $stream, ?string $f
: "form-data; name=\"{$name}\"";
}

// Set a default content-length header if one was no provided
$length = self::getHeader($headers, 'content-length');
if (!$length) {
if ($length = $stream->getSize()) {
$headers['Content-Length'] = (string) $length;
}
}

// Set a default Content-Type if one was not supplied
$type = self::getHeader($headers, 'content-type');
if (!$type && ($filename === '0' || $filename)) {
Expand Down
12 changes: 0 additions & 12 deletions tests/MultipartStreamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,10 @@ public function testSerializesFields(): void
$expected = \implode('', [
"--boundary\r\n",
"Content-Disposition: form-data; name=\"foo\"\r\n",
"Content-Length: 3\r\n",
"\r\n",
"bar\r\n",
"--boundary\r\n",
"Content-Disposition: form-data; name=\"baz\"\r\n",
"Content-Length: 3\r\n",
"\r\n",
"bam\r\n",
"--boundary--\r\n",
Expand Down Expand Up @@ -102,7 +100,6 @@ public function testSerializesNonStringFields(): void
$expected = \implode('', [
"--boundary\r\n",
"Content-Disposition: form-data; name=\"int\"\r\n",
"Content-Length: 1\r\n",
"\r\n",
"1\r\n",
"--boundary\r\n",
Expand All @@ -112,12 +109,10 @@ public function testSerializesNonStringFields(): void
'--boundary',
"\r\n",
"Content-Disposition: form-data; name=\"bool2\"\r\n",
"Content-Length: 1\r\n",
"\r\n",
"1\r\n",
"--boundary\r\n",
"Content-Disposition: form-data; name=\"float\"\r\n",
"Content-Length: 3\r\n",
"\r\n",
"1.1\r\n",
"--boundary--\r\n",
Expand Down Expand Up @@ -165,19 +160,16 @@ public function testSerializesFiles(): void
$expected = \implode('', [
"--boundary\r\n",
"Content-Disposition: form-data; name=\"foo\"; filename=\"bar.txt\"\r\n",
"Content-Length: 3\r\n",
"Content-Type: text/plain\r\n",
"\r\n",
"foo\r\n",
"--boundary\r\n",
"Content-Disposition: form-data; name=\"qux\"; filename=\"baz.jpg\"\r\n",
"Content-Length: 3\r\n",
"Content-Type: image/jpeg\r\n",
"\r\n",
"baz\r\n",
"--boundary\r\n",
"Content-Disposition: form-data; name=\"qux\"; filename=\"bar.unknown\"\r\n",
"Content-Length: 3\r\n",
"Content-Type: application/octet-stream\r\n",
"\r\n",
"bar\r\n",
Expand Down Expand Up @@ -208,7 +200,6 @@ public function testSerializesFilesWithMixedNewlines(): void
$expected = \implode('', [
"--boundary\r\n",
"Content-Disposition: form-data; name=\"newlines\"; filename=\"newlines.txt\"\r\n",
"Content-Length: {$contentLength}\r\n",
"Content-Type: text/plain\r\n",
"\r\n",
"{$content}\r\n",
Expand Down Expand Up @@ -243,7 +234,6 @@ public function testSerializesFilesWithCustomHeaders(): void
"--boundary\r\n",
"x-foo: bar\r\n",
"content-disposition: custom\r\n",
"Content-Length: 3\r\n",
"Content-Type: text/plain\r\n",
"\r\n",
"foo\r\n",
Expand Down Expand Up @@ -287,14 +277,12 @@ public function testSerializesFilesWithCustomHeadersAndMultipleValues(): void
"--boundary\r\n",
"x-foo: bar\r\n",
"content-disposition: custom\r\n",
"Content-Length: 3\r\n",
"Content-Type: text/plain\r\n",
"\r\n",
"foo\r\n",
"--boundary\r\n",
"cOntenT-Type: custom\r\n",
"Content-Disposition: form-data; name=\"foo\"; filename=\"baz.jpg\"\r\n",
"Content-Length: 3\r\n",
"\r\n",
"baz\r\n",
"--boundary--\r\n",
Expand Down