Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

It is impossible to set blank 'Content-Type' header #313

Closed
izhovnir opened this issue Apr 7, 2016 · 0 comments
Closed

It is impossible to set blank 'Content-Type' header #313

izhovnir opened this issue Apr 7, 2016 · 0 comments

Comments

@izhovnir
Copy link

izhovnir commented Apr 7, 2016

This bug is actual mainly for using Ajax.Request along with FormData().
setRequestHeaders() method always sets 'Content-Type' header, even if contentType and encoding options are not defined. It causes incorrect header for Chrome (with comma before the string) that forces to define contentType and enconding. In this case boundary, which is required for multipart/form-data, is missing.

Probable solution:

Replace

if (this.method == 'post') {
      headers['Content-type'] = this.options.contentType + (this.options.encoding ? '; charset=' + this.options.encoding : '');
...
}

to

if (this.method == 'post') {
    if (this.options.contentType || this.options.encoding) { 
        headers['Content-type'] = this.options.contentType + (this.options.encoding ? '; charset=' + this.options.encoding : '');
     } else if (this.options.contentType == '' && this.options.encoding == '') {
         delete headers['Content-type'];
     }
...
}

It will resolve this problem

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

No branches or pull requests

1 participant