# PUTs without "Content-Length" header line are rejected with a 411

**URL:** <https://www.ruby-forum.com/t/puts-without-content-length-header-line-are-rejected-with-a-411/186461>\
**Category:** NGINX\
**Created:** [April 7, 2010, 1:57pm UTC](https://www.ruby-forum.com/t/puts-without-content-length-header-line-are-rejected-with-a-411/186461 "2010-04-07T13:57:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![John\_Griffin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@John\_Griffin](https://www.ruby-forum.com/u/John_Griffin)\
**Post date:** [April 7, 2010, 1:57pm UTC](https://www.ruby-forum.com/t/puts-without-content-length-header-line-are-rejected-with-a-411/186461/1 "2010-04-07T13:57:44Z")

</div>

Hey

I am using nginx to proxy couchdb. Performing the following returns a  
411  
Length Required:

curl -X PUT [https://testing.com/abc](https://testing.com/abc) --insecure --user john

Whereas passing a length of 0 in works fine:

curl -X PUT [https://testing.com/abc](https://testing.com/abc) --insecure --header Content-Length:0  
–user john

Logging also shows it was rejected:

2010/04/03 14:41:20 [info] 22970#0: \*1 client sent PUT method without  
“Content-Length” header while reading client request headers, client:  
10.211.55.2, server: [testing.com](http://testing.com), request: “PUT /abc HTTP/1.1”, host: "  
[testing.com](http://testing.com)"

It seems that this was fixed for POSTs in 0.7.25 but not for PUTs.  
Shouldn’t  
PUTs be allowed without a Content-Length set?

My config is below including an attempt to use proxy\_set\_header to set  
the  
content-length. Unfortunately nginx rejects the request before it gets  
there.

Thanks

John Griffin

server {  
listen 80;  
server\_name [testing.com](http://testing.com);  
rewrite ^/(.\*) [https://testing.com/$1](https://testing.com/$1) permanent;  
}

server {  
listen 443;  
ssl on;  
ssl\_certificate /etc/ssl/certs/myssl.crt;  
ssl\_certificate\_key /etc/ssl/private/myssl.key;  
server\_name [testing.com](http://testing.com);  
access\_log /home/john/public\_html/testing.com/logs/access.log;  
error\_log /home/john/public\_html/testing.com/logs/error.log  
debug;  
error\_page 502 503 504 /error/50x.html;  
location /error/50x.html {  
internal;  
}  
location / {  
set $new\_length $content\_length;  
if ($new\_length = “”) {  
set $new\_length “0”;  
}  
auth\_basic “Restricted”;  
auth\_basic\_user\_file /etc/sites/htpasswd/testing.com;  
proxy\_pass [http://localhost:5984](http://localhost:5984);  
proxy\_redirect off;  
proxy\_set\_header Content-Length $new\_length;  
proxy\_set\_header Host $host;  
proxy\_set\_header X-Real-IP $remote\_addr;  
proxy\_set\_header X-Forwarded-For  
$proxy\_add\_x\_forwarded\_for;  
}  
}

---

<div class="post-metadata">

**Author:** ![John\_Griffin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/f14d63/32.png) [@John\_Griffin](https://www.ruby-forum.com/u/John_Griffin)\
**Post date:** [December 22, 2010, 2:51pm UTC](https://www.ruby-forum.com/t/puts-without-content-length-header-line-are-rejected-with-a-411/186461/2 "2010-12-22T14:51:37Z")

</div>

Yeah, this practically renders proxied WEBDAV servers unusable. 😕

Posted at Nginx Forum:

> **[Re: PUTs without "Content-Length" header line are rejected with a 411](https://forum.nginx.org/read.php?2,72279,160404#msg-160404)**
>
> Hey I am using nginx to proxy couchdb. Performing the following returns a 411 Length Required: curl -X PUT https://testing.com/abc --insecure --user john Whereas passing a length of 0 in works fine: curl -X PUT https://testing.com/abc --insec
