Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 08a6428

Browse filesBrowse files
bug #59763 [HttpClient] Don't send any default content-type when the body is empty (nicolas-grekas)
This PR was merged into the 6.4 branch. Discussion ---------- [HttpClient] Don't send any default content-type when the body is empty | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - | License | MIT Issue was introduced in #49911 Commits ------- 4a475e0 [HttpClient] Don't send any default content-type when the body is empty
2 parents 5e433ee + 4a475e0 commit 08a6428
Copy full SHA for 08a6428

File tree

1 file changed

+4
-2
lines changed
Filter options

1 file changed

+4
-2
lines changed

‎src/Symfony/Component/HttpClient/HttpClientTrait.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/HttpClient/HttpClientTrait.php
+4-2
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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.