jimmywarting / FormData

HTML5 `FormData` polyfill for Browsers and nodejs
MIT License
360 stars 102 forks source link

in ios 10.3 formData be text/plain #111

Closed lvjunling closed 4 years ago

lvjunling commented 4 years ago

when i include formdata-polyfill@3.0.19, i found use new formData the xmlhttprequest content-type be text/plain

jimmywarting commented 4 years ago
  1. formdata-polyfill dose not set any text/plain anywere in the code.
  2. FormData don't override to the request header content-type if it was set by you manually. witch it most likely did
  3. the FormData-polyfill isn't really sending a FormData, it's sending a generated Blob instead. and the default method is to send the Blob's type as content-type
  4. if you use jQuery you probably most likely have to disable 2 options
    $.ajax({
        url: '',
        data: formData,
        processData: false,
        contentType: false
    });

Maybe you can provide a small reproducible jsfiddle or show me some code how you use it?

jimmywarting commented 4 years ago

reason why our patched xhr.send method don't set the content-type is cuz there is no way to get/delete/override request headers that have been set earlier by xhr.setRequestHeader so it will only append and send multiple headers with same name/value