Skip to content
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

Don't auto set content-type if using FormData #140

Merged
merged 2 commits into from
Feb 20, 2015
Merged

Don't auto set content-type if using FormData #140

merged 2 commits into from
Feb 20, 2015

Conversation

marbemac
Copy link

When the request body is a FormData object, Fetch automatically assigns the Content-Type header to "multipart/form-data; boundary={UNIQUE BOUNDARY TOKEN}". If Content-Type is already set, Fetch will not overwrite it. Thus, to support the multipart/form-data content-type, Marty should not automatically set the Content-Type to "application/json" when the request body is a FormData object.

@jhollingworth jhollingworth mentioned this pull request Feb 20, 2015
50 tasks
@jhollingworth
Copy link
Contributor

Awesome, thanks for this :) Is there any chance you could write a test to cover this case?

When request body is a FormData object, don't set the Content-Type header.

When request body is not a FormData object, default the request header to application/json (existing behavior).
@marbemac
Copy link
Author

All set! The tests I added follow a slightly different format, since in this case we're testing the request options, and in all the other cases we're testing the response.

@jhollingworth
Copy link
Contributor

Looks great! Thanks for contributing 😄 This should be hopefully released in a week or two

jhollingworth added a commit that referenced this pull request Feb 20, 2015
Don't auto set content-type if using FormData
@jhollingworth jhollingworth merged commit 820c54d into martyjs:master Feb 20, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants