plans for chunked encoding

Maxim Dounin mdounin at mdounin.ru
Thu Nov 22 16:24:29 UTC 2012


Hello!

On Thu, Nov 22, 2012 at 03:15:38PM +0100, Luka Perkov wrote:

> Hi Maxim,
> 
> On Fri, Nov 16, 2012 at 02:17:58PM +0100, Luka Perkov wrote:
> > On Fri, Nov 16, 2012 at 03:48:55PM +0400, Maxim Dounin wrote:
> > > > On Fri, Oct 19, 2012 at 06:13:10PM +0400, Maxim Dounin wrote:
> > > > > > I'm wondering if there is any work done on this already ? If so I could
> > > > > > test some patches...
> > > > > 
> > > > > I'll post it here once there is something to test.
> > > > 
> > > > Thank you.
> > > 
> > > JFYI, chunked request body patches are available here:
> > > 
> > > http://mailman.nginx.org/pipermail/nginx-devel/2012-November/002961.html
> > > 
> > > Review and testing appreciated.
> > 
> > Thank you for the patches. I'll test them this weekend (or early next
> > week) and I'll give you my feedback after that.
> 
> I have started testing your patches. I'm working on dummy module for
> dealing with post requests, but in the meantime I have a question.
> 
> This is the dummy post data:
> 
> $ cat > /tmp/post_data << EOF
> test post data
> EOF
> 
> This is what I have tested:
> 
> $ curl -v -X GET http://127.0.0.1:80/
> 
> Returns 404 in headers and html body as expected.
> 
> $ curl -v -X POST -d "@/tmp/post_data" http://127.0.0.1:80/
> 
> Returns 404 in headers and html body as expected.
> 
> $ curl -v -X POST -d "@/tmp/post_data" --header "Transfer-Encoding: chunked" http://127.0.0.1:80/
> 
> Returns 404 in headers and html body as expected.
> 
> $ curl -v -X POST -d "@/dev/null" http://127.0.0.1:80/
> 
> Returns 404 in headers and html body as expected.
> 
> $ curl -v -X POST -d "@/dev/null" --header "Transfer-Encoding: chunked" http://127.0.0.1:80/
> 
> Returns 404 in headers but 500 in html body. Is this how it's supposed to be ?

I don't see 500 here, but last curl command produces incorrect 
http request.  Here is a dump (url was slightly modified to match 
my sandbox):

20:17:08.787666 IP 127.0.0.1.57689 > 127.0.0.1.8080: P 1:240(239) ack 1 win 35840 <nop,nop,timestamp 94063983 94063983>
	0x0000:  4500 0123 465d 4000 4006 f575 7f00 0001  E..#F]@. at ..u....
	0x0010:  7f00 0001 e159 1f90 9ff4 3616 6c27 21eb  .....Y....6.l'!.
	0x0020:  8018 8c00 9e71 0000 0101 080a 059b 4d6f  .....q........Mo
	0x0030:  059b 4d6f 504f 5354 202f 666f 6f62 6172  ..MoPOST./foobar
	0x0040:  2048 5454 502f 312e 310d 0a55 7365 722d  .HTTP/1.1..User-
	0x0050:  4167 656e 743a 2063 7572 6c2f 372e 3231  Agent:.curl/7.21
	0x0060:  2e33 2028 6933 3836 2d70 6f72 7462 6c64  .3.(i386-portbld
	0x0070:  2d66 7265 6562 7364 362e 3229 206c 6962  -freebsd6.2).lib
	0x0080:  6375 726c 2f37 2e32 312e 3320 4f70 656e  curl/7.21.3.Open
	0x0090:  5353 4c2f 302e 392e 3765 207a 6c69 622f  SSL/0.9.7e.zlib/
	0x00a0:  312e 322e 330d 0a48 6f73 743a 2031 3237  1.2.3..Host:.127
	0x00b0:  2e30 2e30 2e31 3a38 3038 300d 0a41 6363  .0.0.1:8080..Acc
	0x00c0:  6570 743a 202a 2f2a 0d0a 5472 616e 7366  ept:.*/*..Transf
	0x00d0:  6572 2d45 6e63 6f64 696e 673a 2063 6875  er-Encoding:.chu
	0x00e0:  6e6b 6564 0d0a 436f 6e74 656e 742d 5479  nked..Content-Ty
	0x00f0:  7065 3a20 6170 706c 6963 6174 696f 6e2f  pe:.application/
	0x0100:  782d 7777 772d 666f 726d 2d75 726c 656e  x-www-form-urlen
	0x0110:  636f 6465 640d 0a0d 0a30 0d0a 0d0a 300d  coded....0....0.
	0x0120:  0a0d 0a                                  ...

As you can see there are two final chunks ("0" CRLF CRLF), which 
is incorrect.  In nginx error log it can be seen as:

2012/11/22 20:17:08 [info] 82190#0: *5 client sent invalid method while reading client pipelined request line, client: 127.0.0.1, server: , request: "0"

And corresponding access log entries:

127.0.0.1 - - [22/Nov/2012:20:17:08 +0400] "POST /foobar HTTP/1.1" 404 168 "-" "curl/7.21.3 (i386-portbld-freebsd6.2) libcurl/7.21.3 OpenSSL/0.9.7e zlib/1.2.3"
127.0.0.1 - - [22/Nov/2012:20:17:08 +0400] "0" 400 172 "-" "-"

Two responses are returned as per http protocol, one with 404 (in 
headers and body), and another one with 400 Bad Request (again, in 
headers and body).

If you indeed see 500 in body it might be something to do with 
either your module or nginx config you use.

-- 
Maxim Dounin
http://nginx.com/support.html



More information about the nginx-devel mailing list