Skip to content

Commit a92e4e0

Browse files
committed
The multipart/form-data uses the UTF-8 charset by default
1 parent adc65a6 commit a92e4e0

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Request.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ protected function getMultipartBody() : string
147147
$boundary = \str_repeat('-', 24) . \substr(\md5(\implode("\r\n", $bodyParts)), 0, 16);
148148
$this->setHeader(
149149
RequestHeader::CONTENT_TYPE,
150-
'multipart/form-data; charset=UTF-8; boundary=' . $boundary
150+
'multipart/form-data; boundary=' . $boundary
151151
);
152152
foreach ($bodyParts as &$part) {
153153
$part = "--{$boundary}\r\n{$part}";
@@ -384,7 +384,7 @@ public function setFiles(array $files) : static
384384
{
385385
if ($files) {
386386
$this->tryUpgradeFromGetToPost();
387-
$this->setContentType('multipart/form-data');
387+
$this->setContentType('multipart/form-data', null);
388388
}
389389
$this->files = $files;
390390
return $this;

tests/RequestTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public function testFiles() : void
127127
self::assertNull($this->request->getHeader('content-type'));
128128
$this->request->setFiles(['upload' => __FILE__]);
129129
self::assertSame(
130-
'multipart/form-data; charset=UTF-8',
130+
'multipart/form-data',
131131
$this->request->getHeader('content-type')
132132
);
133133
self::assertTrue($this->request->hasFiles());
@@ -252,7 +252,7 @@ public function testToStringMultipart() : void
252252
]);
253253
$message = (string) $request;
254254
self::assertStringContainsString(
255-
'Content-Type: multipart/form-data; charset=UTF-8; boundary=',
255+
'Content-Type: multipart/form-data; boundary=',
256256
$message
257257
);
258258
self::assertStringContainsString(

0 commit comments

Comments
 (0)