Status code '201 Created' and chunked transfer hangs / times-out

Graham King graham at gkgk.org
Thu Nov 5 10:26:46 MSK 2009


Using nginx/fastcgi, this PHP script will cause the browser to hang
until the keep-alive timeout passes:

<?php
header("HTTP/1.1 201 Created");
?>

Any of the following fix it:
- Changing the status code to 200, 202, etc
- Preventing chunking, by adding a Content-Length header:
header("Content-Length: 0");
- Switching off keep alive (keepalive_timeout  0;)

It seems the problem is with HTTP code 201, chunked transfer encoding,
and keep alive.  The browser is not getting told that all data has
been sent.
I'm not familiar with the nginx code, but these two sections look
relevant, as they seem to treat 201 like the 'no content' status
codes.
http://lxr.evanmiller.org/http/source/http/ngx_http_special_response.c#L402
http://lxr.evanmiller.org/http/source/http/modules/ngx_http_chunked_filter_module.c#L55

>From RFC 2616, 201 seems to be allowed content: "The response SHOULD
include an entity containing a list of resource characteristics and
location(s)"

The script works fine in Apache/mod_php.
I'm using the default Ubuntu setup of nginx with the fastcgi part
commented back in, and serving php with "php-cgi -b 127.0.0.1:9000". I
get the same problem when using nginx as a front-end to
Apache/mod_wsgi.

Am I missing something?

Many thanks in advance,
Graham





More information about the nginx mailing list