LPology / Simple-Ajax-Uploader

Javascript file upload plugin with progress bar support. Works in all major browsers, including IE7+, Chrome, Firefox, Safari, and Opera. No dependencies - use it with or without jQuery.
995 stars 267 forks source link

Accept header is encoded causing 406 Not Acceptable #98

Closed MauriceS closed 8 years ago

MauriceS commented 9 years ago

I have set the option responseType to json.

When uploading a file to my service, I get a 406 Not Acceptable error due to encoding of the "Accept" header.

header["Accept"]: application%2Fjson%2C%20text%2Fjavascript%2C%20%2F%3B%20q%3D0.01

it should be

header["Accept"]: application/json, text/javascript, /; q=0.01

This issue is similar to issue #93

This is the problematic code snippet:

for ( var i in headers ) {
        if ( headers.hasOwnProperty( i ) ) {
            xhr.setRequestHeader( i, encodeURIComponent(headers[ i ]) + '' );
        }
    }

As a dirty workaround I just have inserted an if statement that excludes the "Accept" header from encoding.

arjan commented 9 years ago

Actually, Request headers do not need to be encoded at all.

LPology commented 8 years ago

This issue is fixed with version 2.3.