8000 [HttpClient] Don't send any default content-type when the body is empty · symfonyaml/symfony@4a475e0 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4a475e0

Browse files
[HttpClient] Don't send any default content-type when the body is empty
1 parent 8c6b79c commit 4a475e0

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Symfony/Component/HttpClient/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)
0