Is there a way to avoid nginx 411 Content-Length required errors?

I'm getting a 411 status back from nginx when trying to do a PUT without specifying the content-length. Is there any way to disable this from happening?


You could try to add this to your query :

curl -i -X PUT -H 'Content-Length: 0' 'http://www.example.com/test'

Try to install the HttpChunkinModule or update Nginx to 1.3.9+

This module is no longer needed for Nginx 1.3.9+ because since 1.3.9, the Nginx core already has built-in support for the chunked request bodies.


PUT requests require Content-Length. It's not Nginx, it's HTTP that's making this requirement. PUT request, like POST requests, necessarily have a content body. That body can be zero-length, but if it is then you have to explicitly say so. Obviously you can't assume that the content continues until the connection is closed (which is what an absent content-length header implies), because the server has to be able to respond to the request before the connection is closed.


Old-ish question, but since I stumbled into this from a web search:

NginX 1.3.9 and above supports "Transfer-Encoding: chunked" out of the box for POST and PUT.

With chunked transfer, you can send files without setting content-length first.