Forms with enctype set as multipart/form-data get submited with the default application/x-www-form-urlencoded #168
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hi guys, i've been struggling with something that i believe is a bug on this excellent library:
From the previous threads and the documentation, my understanding was that forms submitted through pjax are submitted with a content type set to "application/x-www-form-urlencoded".
However, if the form has a enctype set to "multipart/form-data", the pjax call is supposed to use this value and set the header Content-Type to this value.
I can't make it work on my server (Apache/PHP7) and despite the required enctype my data are sent as "application/x-www-form-urlencoded".
the formData is set properly, and using the debug mode, i can see that the reight object is used to pass the form data to my backend.
But when i look to the post request, the content-type is not changed, so my PHP script cannot handle the data properly.
find a the following capture describing what i believe is an issue :




Hi @davidSocast, thanks for reporting this. Yes, looks like this is a bug as the
Content-Typeheader is currently always set to"application/x-www-form-urlencoded"when submitting a form:e49d8947f7/lib/send-request.js (L70-L73)We'll look to fix this in the next release of the library.
The fix for this should be simple: just add
&& !formDatato theifstatement. However, when I started writing tests for this, I ran into what I think is a bug in jsdom. So I'm going to wait until that's resolved to work on this.The issue I opened in jsdom has not had a response in 3 weeks, so I'm submitting the fix for this, and the tests will have to wait.