This repository has been archived by the owner on Feb 24, 2024. It is now read-only.
Negotiate Response Content-Type from request's Accept header. #1403
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #1148
This changes the default Context to negotiate the response
Content-Type
using the request'sAccept
header exclusively, instead of including the request'sContent-Type
in the negotiation. Failed negotiation will default to usingrender.Options#DefaultContentType
. (This is important because Internet Explorer does not pass an Accept header that negotiates HTML.)This is not backwards compatible
HTTP clients using
Content-Type
instead ofAccept
in their request headers will not work the same way. Code that overrides these values (such as those using https://github.com/gobuffalo/mw-contenttype) will no longer have the desired effect. They should be removed in favor of theDefaultContentType
option or a middleware that sets theAccept
header.gobuffalo/httptest#2 is needed for tests to passMerged!