Skip to content

Commit 3294a43

Browse files
[HttpClient] Don't send any default content-type when the body is empty
1 parent 687e032 commit 3294a43

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

HttpClientTrait.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,11 @@ private static function normalizeBody($body, array &$normalizedHeaders = [])
356356
}
357357
});
358358

359-
$body = http_build_query($body, '', '&');
359+
if ('' === $body = http_build_query($body, '', '&')) {
360+
return '';
361+
}
360362

361-
if ('' === $body || !$streams && !str_contains($normalizedHeaders['content-type'][0] ?? '', 'multipart/form-data')) {
363+
if (!$streams && !str_contains($normalizedHeaders['content-type'][0] ?? '', 'multipart/form-data')) {
362364
if (!str_contains($normalizedHeaders['content-type'][0] ?? '', 'application/x-www-form-urlencoded')) {
363365
$normalizedHeaders['content-type'] = ['Content-Type: application/x-www-form-urlencoded'];
364366
}

0 commit comments

Comments
 (0)