Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

ContentType for FormData message-body #5

Closed
rnicholus opened this issue Jul 1, 2014 · 3 comments · Fixed by #46
Closed

ContentType for FormData message-body #5

rnicholus opened this issue Jul 1, 2014 · 3 comments · Fixed by #46

Comments

@rnicholus
Copy link
Contributor

When the message-body of an ajax request consists (initially) of a FormData object, the Content-Type of the response must be set by the UA. Just as a form submit where the form's enctype is "multipart/form-data", the UA will set the Content-Type of the request to "multipart/form-data" along with a calculated multipart boundary identifier. This is required for the server to easily parse the message-body.

I noticed that <core-ajax> has a default Content-Type of "application/x-www-form-urlencoded". If the contentType on the element instance isn't explicitly set to another value, this will be the Content-Type of the request. So, if the payload is a FormData object, the contentType must be nulled out in order to prevent <core-ajax> from setting the Content-Type, so the UA can properly set it.

It's not difficult to null out the contentType on the element instance, but it's not intuitive. Perhaps <core-ajax> should avoid setting the Content-Type of the request if the payload is a FormData object, since the Content-Type for this type of message-body must always be left alone so the UA can set it properly.

I can open up a PR with required changes, if you concur.

@garlicnation
Copy link
Contributor

I'm happy to take a look at a PR for this issue.

@rnicholus
Copy link
Contributor Author

Great! I'll put something together as soon as I can. Should be straightforward.

@rnicholus
Copy link
Contributor Author

@garlicnation I've opened up a PR - #46.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants