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

agentzh agentzh at gmail.com
Tue Nov 17 06:28:18 MSK 2009


On Mon, Nov 16, 2009 at 7:48 PM, wangkai <nginx-forum at nginx.us> wrote:
> Hi, agentzh
>
> You are so awesome for the "thunkin" module implementation of ngix.

Well, I'm assuming you're serious. It's "chunkin" not "thunkin" :)

> I am a beginner for ngix and linux.
> I don't know how to do a little for your "thunkin" module.
>

To show how this module works in action, I'd use the "echo" module to
demonstrate the actual effect.

With both "echo" and "chunkin" modules compiled into your nginx, you
can try the following configuration:

    chunkin on;
    location /body {
        echo_read_request_body;           # try to read the request body
        echo_request_body;                    # emit the request body
        echo;                                            # print out a
trailing new line
    }

Then from your command line:

  $ curl -d 'hello, world' -H 'Transfer-Encoding: chunked'
'http://localhost/body'
  hello, world

  $ curl -d 'hello, world' 'http://localhost/body'
  hello, world

The first "curl" command enforces the "chunked" encoding to be used in
the HTTP request.

Then try turning off the "chunkin" directive:

    chunkin off;                                      # turn off this module
    location /body {
        echo_read_request_body;           # try to read the request body
        echo_request_body;                    # emit the request body
        echo;                                            # print out a
trailing new line
    }

And try to send the previous requests again:

  $ curl -d 'hello, world' -H 'Transfer-Encoding: chunked'
'http://localhost/body'
  <html>
  <head><title>411 Length Required</title></head>
  <body bgcolor="white">
  <center><h1>411 Length Required</h1></center>
  <hr><center>nginx/0.8.24</center>
  </body>
  </html>

  $ curl -d 'hello, world' 'http://localhost/body'
  hello, world

The first response just shows the fact that nginx does not support the
"chunked" encoding itself while the second just tests the normal
transfer encoding :)

Note that the "chunkin" module does not rely on "echo" to function. I
just used "echo" for the sake of easy demonstration. FWIW, I also
makes heavy use of the "echo" module in the test suite of the
"chunkin" module, for example,

   http://github.com/agentzh/chunkin-nginx-module/blob/master/test/t/sanity.t

I'd add this demo to the "chunkin" module's wiki page later:

    http://wiki.nginx.org/NginxHttpChunkinModule

Please consult the "echo" module's wiki page for more detailed
explanation for the directives used above:

    http://wiki.nginx.org/NginxHttpEchoModule

Cheers,
-agentzh





More information about the nginx mailing list