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

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

From RFC 2616, 201 seems to be allowed content: “The response SHOULD
include an entity containing a list of resource characteristics and

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”. I
get the same problem when using nginx as a front-end to

Am I missing something?

Many thanks in advance,