-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[HttpFoundation] fix not sending Content-Type header for 204 responses #35709
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
} else { | ||
// Content-type based on the Request | ||
if (!$headers->has('Content-Type')) { | ||
$format = $request->getPreferredFormat(); | ||
$format = $request->getPreferredFormat(null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The Content-Type gets set to html anyway a few lines below (284). So we don't to ask for the html default here. Otherwise line 284 is basically unreachable.
e868336
to
06f5a11
Compare
@@ -267,10 +267,12 @@ public function prepare(Request $request) | ||
$this->setContent(null); | ||
$headers->remove('Content-Type'); | ||
$headers->remove('Content-Length'); | ||
// prevent PHP from sending the Content-Type header based on default_mimetype | ||
ini_set('default_mimetype', ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be merged in 3.4 as well, right?
Thank you @Tobion. |
…04 responses (Tobion) This PR was merged into the 4.4 branch. Discussion ---------- [HttpFoundation] fix not sending Content-Type header for 204 responses | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | | License | MIT | Doc PR | `$headers->remove('Content-Type')` did not actually work because PHP sends the Content-Type header based on the https://www.php.net/manual/en/ini.core.php#ini.default-mimetype ini setting anyway (which defaults to html). So we need to disable this ini for empty responses. Commits ------- 06f5a11 [HttpFoundation] fix not sending Content-Type header for 204 responses
$headers->remove('Content-Type')
did not actually work because PHP sends the Content-Type header based on the https://www.php.net/manual/en/ini.core.php#ini.default-mimetype ini setting anyway (which defaults to html). So we need to disable this ini for empty responses.