martyjs / marty

A Javascript library for state management in React applications
http://martyjs.org
MIT License
1.09k stars 76 forks source link

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

Closed marbemac closed 9 years ago

marbemac commented 9 years ago

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 commented 9 years ago

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

marbemac commented 9 years ago

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 commented 9 years ago

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