@@ -39,10 +39,13 @@ public function __construct(HttpClientInterface $client = null, History $history
39
39
parent ::__construct ([], $ history , $ cookieJar );
40
40
}
41
41
42
+ /**
43
+ * @param Request $request
44
+ */
42
45
protected function doRequest ($ request ): Response
43
46
{
44
47
$ headers = $ this ->getHeaders ($ request );
45
- [$ body , $ extraHeaders ] = $ this ->getBodyAndExtraHeaders ($ request );
48
+ [$ body , $ extraHeaders ] = $ this ->getBodyAndExtraHeaders ($ request, $ headers );
46
49
47
50
$ response = $ this ->client ->request ($ request ->getMethod (), $ request ->getUri (), [
48
51
'headers ' => array_merge ($ headers , $ extraHeaders ),
@@ -56,7 +59,7 @@ protected function doRequest($request): Response
56
59
/**
57
60
* @return array [$body, $headers]
58
61
*/
59
- private function getBodyAndExtraHeaders (Request $ request ): array
62
+ private function getBodyAndExtraHeaders (Request $ request, array $ headers ): array
60
63
{
61
64
if (\in_array ($ request ->getMethod (), ['GET ' , 'HEAD ' ])) {
62
65
return ['' , []];
@@ -67,6 +70,10 @@ private function getBodyAndExtraHeaders(Request $request): array
67
70
}
68
71
69
72
if (null !== $ content = $ request ->getContent ()) {
73
+ if (isset ($ headers ['content-type ' ])) {
74
+ return [$ content , []];
75
+ }
76
+
70
77
$ part = new TextPart ($ content , 'utf-8 ' , 'plain ' , '8bit ' );
71
78
72
79
return [$ part ->bodyToString (), $ part ->getPreparedHeaders ()->toArray ()];
0 commit comments