DELETE request issued to nginx back-end fails with 411 #338

Closed
wants to merge 4 commits into
from

Projects

None yet

5 participants

@mmalecki

Interesting. I'll accept it, but please fix coding style:

if (req.method === 'DELETE') {
  req.headers['content-length'] = '0';
}

and make sure that indentation matches rest of the code. Thanks!

@ian7
@indexzero
nodejitsu member

Reluctantly +1

@rc1

In my case, as an observation, nginx is stripping the header's 'content-length'. When I run locally 'content-length' exists on the req and when I run remotely heroku 'content-length' is stripped from the req. The easy fix for me was to just add it back to the req before passing to node-http-proxy.

@andreareginato

Similar problem for CORS features. When the browser makes the preflight requestI get a 411 error. As far as the preflight is automatically made from the browser there is no way to set content-length to 0 and CORS will never work with node http proxy.

@mmalecki

Actually, now that I think about it, a DELETE request can have a body. We happen to use such requests ourselves in production.
We should check if a Content-Length is already defined, I think.
@indexzero @ian7 opinions?

@andreareginato

That is true. I check is needed. I would add also OPTIONS (for CORS preflight) on the list of verbs to check.

@indexzero indexzero added a commit that closed this pull request Mar 9, 2013
@indexzero indexzero [fix] Set "content-length" header to "0" if it is not already set on …
…DELETE requests. Fixes #338.
9be0af3
@indexzero indexzero closed this in 9be0af3 Mar 9, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment