The "chunkin" module: Experimental chunked input support for Nginx

agentzh agentzh at
Sun Nov 15 13:27:41 MSK 2009

Hi, folks!

Pushed by those cutting-edge users on the list, I've quickly worked
out "chunkin" module which adds HTTP 1.1 chunked input support for
Nginx without the need to patching the core:

This module registers an access-phase handler that will eagerly read
and decode incoming request bodies when a "Transfer-Encoding: chunked"
header triggers a 411 error page in Nginx (hey, that's what you have
to pay for avoiding patching the core ;)). For requests that are not
in the "chunked" transfer encoding, this module is a "no-op".

To enable the magic, just turn on the "chunkin" config option like this:

  chunkin on;
  location /foo { ... }

No other modification is required in your nginx.conf file. (The
"chunkin" directive is not allowed to use in the location block BTW.)

This module is still considered highly experimental and there must be
some serious bugs lurking somewhere. But you're encouraged to play and
test it in your non-production environment and report any quirks to me

Efforts have been made to reduce data copying, dynamic memory
allocation, and other performance tuning, thus unfortunately raising
the risk of potential buffer handling bugs caused by premature
optimizations :P

This module is not supposed to be merged into the Nginx core because
I've used Ragel to generate the chunked encoding parser for joy :)

The following Nginx versions have been successfully tested by this
module's (very limited) test suite:

   0.8.0 ~ 0.8.24
   0.7.21 ~ 0.7.63

The test suite definitely needs more test cases and the code is hacky
in various places. If you're willing to contribute, feel free to ask
me for a commit bit in a private email :)

Have fun!

More information about the nginx mailing list