# Content-Length ###s being served, but no actual content

**URL:** <https://www.ruby-forum.com/t/content-length-s-being-served-but-no-actual-content/229542>\
**Category:** NGINX\
**Created:** [February 13, 2013, 7:54pm UTC](https://www.ruby-forum.com/t/content-length-s-being-served-but-no-actual-content/229542 "2013-02-13T19:54:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tsaavik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecccb3/32.png) [@tsaavik](https://www.ruby-forum.com/u/tsaavik)\
**Post date:** [February 13, 2013, 7:54pm UTC](https://www.ruby-forum.com/t/content-length-s-being-served-but-no-actual-content/229542/1 "2013-02-13T19:54:57Z")

</div>

I’ve discovered what I believe to be a bug (yeah I know everyone is  
already  
rolling their eyes) 😃

I believe that my CGI is returning some data (perhaps Content-Type  
header)  
and then is occasionally stalling due to backend load.  
This is fine, and fastcgi\_read\_timeout can be adjusted to deal with the  
issue of course.  
However, it appears that when Nginx times out the connection it still  
serves  
a non-empty Content-Length!

HTTP/1.1 200 OK^M  
Server: nginx/1.2.6^M  
Date: Tue, 05 Feb 2013 20:12:31 GMT^M  
Content-Type: text/x-json^M  
Content-Length: 397^M  
Connection: keep-alive^M  
X-WSL-Version: 1.0^M  
^M  
HTTP/1.1 200 OK^M  
Server: nginx/1.2.6^M  
Date: Tue, 05 Feb 2013 20:12:38 GMT^M  
Content-Type: text/x-json^M  
Content-Length: 396^M  
Connection: keep-alive^M  
^M  
(There is actual JSON data here, I clipped it out, trust me!)

* * *

See that 397 bytes of non-existent data?  
I tested on nginx/0.8.53 and nginx/1.2.6. I’m using netcat6 to run the  
tests  
with http-pipelining.  
I also tried various different kernels, and ran the tests on my local  
network to rule out weird internet stuff.

Posted at Nginx Forum:

> **[Content-Length ###s being served, but no actual content](https://forum.nginx.org/read.php?2,236213,236213#msg-236213)**
>
> I've discovered what I believe to be a bug (yeah I know everyone is already rolling their eyes) :D I believe that my CGI is returning some data (perhaps Content-Type header) and then is occasionally stalling due to backend load. This is fine, and...

---

<div class="post-metadata">

**Author:** ![tsaavik](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/ecccb3/32.png) [@tsaavik](https://www.ruby-forum.com/u/tsaavik)\
**Post date:** [February 14, 2013, 12:08pm UTC](https://www.ruby-forum.com/t/content-length-s-being-served-but-no-actual-content/229542/2 "2013-02-14T12:08:19Z")

</div>

Hello!

On Wed, Feb 13, 2013 at 01:54:08PM -0500, tsaavik wrote:

> HTTP/1.1 200 OK^M  
> Content-Type: text/x-json^M  
> network to rule out weird internet stuff.  
> Here nginx just returns Content-Length it got from the backend,  
> and there is no way to withdraw headers if the problem with  
> backend happens after headers are sent.

What is wrong here is that next pipelined request is answered if  
error happens while reading response body from the backend.  
Instead, client connection should be just closed as there is no  
way to recover.

This is somewhat known problem and it’s resolution waits for the  
upstream module error handling audit. It’s relatively low  
priority though as it doesn’t appear frequently, as the problem  
have to happen after headers are sent, during transmission of a  
response body.

–  
Maxim D.

> **[F5 NGINX: Built for cloud-native apps. Ready for AI traffic.](https://www.f5.com/products/nginx)**
>
> Deliver modern applications with NGINX. Explore high-performance load balancing, API gateways, and web server solutions trusted by top global enterprises.
