-
Notifications
You must be signed in to change notification settings - Fork 22
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
CP-1939 Allow content-type to be set manually #153
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
evanweible-wf
changed the title
Allow content-type to be set manually
CP-1939 Allow content-type to be set manually
Jun 16, 2016
+1 |
Thanks! |
+1 once conflicts are resolved |
evanweible-wf
force-pushed
the
content-type-override
branch
from
June 20, 2016 16:22
e819788
to
13239d4
Compare
@maxwellpeterson-wf @sebastianmalysa-wf Rebased against latest master and fixed a conflict in |
+1 |
Current coverage is 99.53%
|
+1 |
@jayudey-wf ready for merge |
QA Resource Approval: +10
Merging into master. |
3 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Improvement
Currently every request's content-type is set automatically (with the exception of
StreamedRequest
) based on the request type and the encoding. This is too inflexible as there are valid use cases for wanting to override the content-type like integration with a server that expects a certain content-type.It was requested by @stevenosborne-wf that we add support for manually setting the content-type.
Changes
FormRequest.contentType
,JsonRequest.contentType
, andRequest.contentType
can now be set manually.MultipartRequest.contentType
still cannot be set manually because a multipart request requires a specific content-type with a boundary string parameter.StreamedRequest.contentType
was already overridable by consumers since the content is not known prior to opening the request. This is still the case, but I fixed a bug where we weren't verifying that the request had not yet been sent when setting the content-type.Previously, the content-type would be automatically updated when the encoding was changed. This is still the default behavior, but once a user manually sets the content-type, this will stop. In other words, we are assuming that a consumer who sets the content-type manually is intentionally overriding the defaults and is taking responsibility of setting the charset parameter appropriately.
Technically, since the
StreamedRequest
already allowed consumers to manually set the content-type but did not enforce the behavior described in the previous point, the expected behavior of existing code could change in only this exact scenario:Previously, setting
encoding
aftercontentType
would have triggered an update to the content-type to include acharset: utf-8
parameter, but after this change, this will no longer happen.Testing
Code Review
@trentgrover-wf
@maxwellpeterson-wf
@dustinlessard-wf
@jayudey-wf
@sebastianmalysa-wf
@srinivasdhanwada-wf
fyi: @stevenosborne-wf