File tree Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Expand file tree Collapse file tree 2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -176,7 +176,12 @@ interface_exists('JsonSerializable', false) &&
176
176
}
177
177
}
178
178
179
- if (!$ binary_data && (is_array ($ data ) || is_object ($ data ))) {
179
+ if (!$ binary_data &&
180
+ (is_array ($ data ) || is_object ($ data )) &&
181
+ (
182
+ !isset ($ this ->headers ['Content-Type ' ]) ||
183
+ !preg_match ('/^multipart\/form-data/ ' , $ this ->headers ['Content-Type ' ])
184
+ )) {
180
185
$ data = http_build_query ($ data , '' , '& ' );
181
186
}
182
187
Original file line number Diff line number Diff line change @@ -552,6 +552,28 @@ public function testPutFileHandle()
552
552
$ this ->assertEquals ('image/png ' , $ test ->curl ->response );
553
553
}
554
554
555
+ public function testMultipartFormDataContentType ()
556
+ {
557
+ // Use a PUT request instead of a POST request so the request
558
+ // multipart/form-data is not automatically parsed and can be tested
559
+ // against.
560
+ $ test = new Test ();
561
+ $ test ->curl ->setHeader ('Content-Type ' , 'multipart/form-data ' );
562
+ $ test ->server ('put ' , 'PUT ' , array (
563
+ 'foo ' => 'bar ' ,
564
+ ));
565
+
566
+ $ this ->assertEquals ('100-continue ' , $ test ->curl ->requestHeaders ['Expect ' ]);
567
+ $ this ->assertStringStartsWith ('multipart/form-data; boundary= ' , $ test ->curl ->requestHeaders ['Content-Type ' ]);
568
+
569
+ $ expected_contains = "\r\n" .
570
+ 'Content-Disposition: form-data; name="foo" ' . "\r\n" .
571
+ "\r\n" .
572
+ 'bar ' . "\r\n" .
573
+ '' ;
574
+ $ this ->assertContains ($ expected_contains , $ test ->curl ->response );
575
+ }
576
+
555
577
public function testPatchRequestMethod ()
556
578
{
557
579
$ test = new Test ();
You can’t perform that action at this time.
0 commit comments