content-type in FormData for string part #45037
Open
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.
Summary:
When performing an xhr request with
content-type: multipart/form-data
, it is sometimes required to specify acontent-type
header for astring
part of theFormData
. Currently, this is not possible, because theFormData
only sets this header for aBlob
part. This PR addresses this issue, allowing to append a part as "string object" with an optionaltype
property that will be used byFormData.getParts
ascontent-type
headers, like it happens forBlob
right now.Changelog:
[GENERAL] [ADDED] -
FormData.append
function can now accept a "string object" with an optionaltype
parameter that will be used byFormData.getParts
function ascontent-type
headerTest Plan:
before the changes:
there was no way to specify the
content-type
asapplication/json
this produced the following request body:
after the changes, it is possible to eventually specify the type of the appended part like this:
resulting in the following request body, with the correct content-type:
it is still possible to pass directly a string like in the first example, the behaviour will be the same as before the changes