# Nginx/1.3.2 - 4xx responses are returned without HTTP headers, bug?

**URL:** <https://www.ruby-forum.com/t/nginx-1-3-2-4xx-responses-are-returned-without-http-headers-bug/221329>\
**Category:** NGINX\
**Created:** [July 9, 2012, 10:50am UTC](https://www.ruby-forum.com/t/nginx-1-3-2-4xx-responses-are-returned-without-http-headers-bug/221329 "2012-07-09T10:50:23Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [July 9, 2012, 10:50am UTC](https://www.ruby-forum.com/t/nginx-1-3-2-4xx-responses-are-returned-without-http-headers-bug/221329/1 "2012-07-09T10:50:23Z")

</div>

Hi,

I think I stumbled upon a bug in nginx but I would like to get someone  
else’s opinion on this.

It seems all 4xx errors are not prefixed by headers in HTTP responses. I  
have a simple test-script in bash which you can run to verify this  
behavior:

function req { echo -n “GET /bugtest?id=”; for i in `seq 15000 17100` ;  
do echo -n “%7C$i” ; done ; echo -en “HTTP/1.1\nUser-Agent:  
Mozilla/5.0\nConnection: Close\nHost: [wiki.nginx.org](http://wiki.nginx.org)\r\n\r\n” ; } ; req  
| nc [wiki.nginx.org](http://wiki.nginx.org) 80

I can also reproduce this for other 4xx responses. My interpretation of  
the RFC is that this is unwanted, see

> **[RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1](https://datatracker.ietf.org/doc/html/rfc2616)**
>
> HTTP has been in use by the World-Wide Web global information initiative since 1990. This specification defines the protocol referred to as "HTTP/1.1", and is an update to RFC 2068. \[STANDARDS-TRACK\]

If this is not the appropriate place to report this please let me know  
as I couldn’t find a better place to report this.

–

Regards,

Sjon Hortensius

| React B.V.  
| [http://www.react.nl](http://www.react.nl)  
| Julianastraat 30  
| 2012 ES, Haarlem  
| 023 553 90 00

---

<div class="post-metadata">

**Author:** ![Sjon\_Hortensius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@Sjon\_Hortensius](https://www.ruby-forum.com/u/Sjon_Hortensius)\
**Post date:** [July 9, 2012, 11:53am UTC](https://www.ruby-forum.com/t/nginx-1-3-2-4xx-responses-are-returned-without-http-headers-bug/221329/2 "2012-07-09T11:53:06Z")

</div>

Hello!

On Mon, Jul 09, 2012 at 10:41:19AM +0200, Sjon Hortensius wrote:

> 17100` ; do echo -n “%7C$i” ; done ; echo -en “HTTP/1.1\nUser-Agent:  
> Mozilla/5.0\nConnection: Close\nHost: [wiki.nginx.org](http://wiki.nginx.org)\r\n\r\n” ; } ;  
> req | nc [wiki.nginx.org](http://wiki.nginx.org) 80
> 
> I can also reproduce this for other 4xx responses. My interpretation  
> of the RFC is that this is unwanted, see  
> [RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1 | RFC Editor](http://tools.ietf.org/html/rfc2616#section-6.1)

Headers aren’t sent if nginx assumes the request is in HTTP/0.9  
format. The above script makes nginx to think it’s HTTP/0.9 as  
uri used dosn’t fit into header buffer and nginx isn’t able to  
see “HTTP/1.1” before it returns 414.

Maxim D.

---

<div class="post-metadata">

**Author:** ![Sjon\_Hortensius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@Sjon\_Hortensius](https://www.ruby-forum.com/u/Sjon_Hortensius)\
**Post date:** [July 9, 2012, 1:02pm UTC](https://www.ruby-forum.com/t/nginx-1-3-2-4xx-responses-are-returned-without-http-headers-bug/221329/3 "2012-07-09T13:02:04Z")

</div>

On 07/09/2012 11:52 AM, Maxim D. wrote:

> > responses. I have a simple test-script in bash which you can run to
> 
> Headers aren’t sent if nginx assumes the request is in HTTP/0.9  
> format. The above script makes nginx to think it’s HTTP/0.9 as  
> uri used dosn’t fit into header buffer and nginx isn’t able to  
> see “HTTP/1.1” before it returns 414.
> 
> Maxim D.

Thanks for your reply! I have been looking for RFC documents describing  
the maximum request-length in HTTP/0.9, but I cannot find any. I found  
[http://www.w3.org/Protocols/HTTP/Request.html](http://www.w3.org/Protocols/HTTP/Request.html) (which links to  
[http://www.w3.org/Addressing/URL/5\_BNF.html](http://www.w3.org/Addressing/URL/5_BNF.html) to describe URLs) and  
[http://www.ietf.org/rfc/rfc1738.txt](http://www.ietf.org/rfc/rfc1738.txt), both of which describe no maximum  
length.

If nginx assumes HTTP/0.9 for the request, it doesn’t seem very logical  
to return an error which cannot exist within that very protocol?

–

Regards,

Sjon Hortensius

| React B.V.  
| [http://www.react.nl](http://www.react.nl)  
| Julianastraat 30  
| 2012 ES, Haarlem  
| 023 553 90 00

---

<div class="post-metadata">

**Author:** ![Sjon\_Hortensius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@Sjon\_Hortensius](https://www.ruby-forum.com/u/Sjon_Hortensius)\
**Post date:** [July 9, 2012, 2:46pm UTC](https://www.ruby-forum.com/t/nginx-1-3-2-4xx-responses-are-returned-without-http-headers-bug/221329/4 "2012-07-09T14:46:39Z")

</div>

On Mon, Jul 09, 2012 at 01:01:21PM +0200, Sjon Hortensius wrote:

> > > It seems all 4xx errors are not prefixed by headers in HTTP  
> > > [RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1 | RFC Editor](http://tools.ietf.org/html/rfc2616#section-6.1)  
> > > [http://www.w3.org/Protocols/HTTP/Request.html](http://www.w3.org/Protocols/HTTP/Request.html) (which links to  
> > > [http://www.w3.org/Addressing/URL/5\_BNF.html](http://www.w3.org/Addressing/URL/5_BNF.html) to describe URLs) and  
> > > [http://www.ietf.org/rfc/rfc1738.txt](http://www.ietf.org/rfc/rfc1738.txt), both of which describe no maximum  
> > > length.
> 
> If nginx assumes HTTP/0.9 for the request, it doesn’t seem very logical  
> to return an error which cannot exist within that very protocol?

Well, it does not return error. It just returns a page with text:  
“414 Request-URI Too Large”. What can you suggest to return for  
a request larger than configured buffer ?

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![Sjon\_Hortensius](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/a9a28c/32.png) [@Sjon\_Hortensius](https://www.ruby-forum.com/u/Sjon_Hortensius)\
**Post date:** [July 10, 2012, 12:11pm UTC](https://www.ruby-forum.com/t/nginx-1-3-2-4xx-responses-are-returned-without-http-headers-bug/221329/5 "2012-07-10T12:11:57Z")

</div>

On 07/09/2012 02:46 PM, Igor S. wrote:

> > > > of the RFC is that this is unwanted, see  
> > > > the maximum request-length in HTTP/0.9, but I cannot find any. I found  
> > > > a request larger than configured buffer ?  
> > > > When I said it returns an error I obviously meant it returns a HTTP  
> > > > error. Since HTTP/0.9 doesn’t define a maximum length for a URL, it  
> > > > seems strange to return an error about this very length in this specific  
> > > > protocol.

I think the only problem I have with this behavior is nginx falling back  
to HTTP/0.9; a protocol which isn’t used on any network I know. I would  
prefer falling back to HTTP/1.0 which more clients will support,  
although I don’t know what impact this has.

–

Regards,

Sjon Hortensius

| React B.V.  
| [http://www.react.nl](http://www.react.nl)  
| Julianastraat 30  
| 2012 ES, Haarlem  
| 023 553 90 00
