ProgerXP / FileDrop

Self-contained cross-browser pure JavaScript class for Drag & Drop and AJAX (multi) file upload.
filedropjs.org
The Unlicense
264 stars 61 forks source link

Allow custom X-Requested-With Header #28

Closed ghost closed 9 years ago

ghost commented 9 years ago

It should be possible to set X-Requested-With (or just an option for not setting it)

I have server-side code (which I cant change in the near future) which checks if X-Requested-With equals XMLHttpRequest for determining if the request is an ajax request.

ProgerXP commented 9 years ago

You can freely override anything including XHR headers by listening to xhrSetup event: http://filedropjs.org/#fe

zone.on('xhrSetup', function (xhr) {
  xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest')
})
ghost commented 9 years ago

Its possible to add to the header, but its impossible to overwrite it there.

X-Requested-With:FileDrop-XHR-FileAPI, XMLHttpRequest

ProgerXP commented 9 years ago

Hm, right. Well, in this case just disable these headers with extraHeaders option and set X-... yourself. http://filedropjs.org/#fo

ghost commented 9 years ago

Yes, but then i have the file-headers myself to, something which I would like to avoid.

ProgerXP commented 9 years ago

I gave it a second thought and guess there's nothing wrong with opt.xRequestedWith. http://filedropjs.org/#fo