I’m having another strange problem with the chunked request API. Some methods of sending chunks work, while others do not. I can reproduce (see below) the problem.
I've been investigating this all day. It looks like if the client sends the first chunk with the initial request, the WSGI app can't see the data; but if the client sends the first chunk after the initial request, the WSGI app works fine. I can make curl send the first chunk after the initial request by using '-T' to force the use of 'expect: continue'. I've tracked this down into core/chunked.c, in the function uwsgi_chunked_read. It simply times out here waiting. I've strace'd the uwsgi process(es), and I see the packet being received by one process, and the other process just reads the first bit (initial request), then times out polling. I'm afraid this is the limit of my uwsgi splunking fu, unless someone wants to give me a hint. :-) Any ideas? Steve This works: [spierce@memory chunked]$ curl -v -X PUT -T test --header "Transfer-Encoding: chunked" --header "Content-Type: application/binary" "http://localhost:8080/" * About to connect() to localhost port 8080 (#0) * Trying ::1... Connection refused * Trying 127.0.0.1... connected * Connected to localhost (127.0.0.1) port 8080 (#0) > PUT / HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 > zlib/1.2.3 libidn/1.18 libssh2/1.2.2 > Host: localhost:8080 > Accept: */* > Transfer-Encoding: chunked > Content-Type: application/binary > Expect: 100-continue > < HTTP/1.1 100 Continue < HTTP/1.1 200 OK < Content-Length: 0 < * Connection #0 to host localhost left intact * Closing connection #0 This doesn't: [spierce@memory chunked]$ curl -v -X PUT --data-binary @test --header "Transfer-Encoding: chunked" --header "Content-Type: application/binary" "http://localhost:8080/" * About to connect() to localhost port 8080 (#0) * Trying ::1... Connection refused * Trying 127.0.0.1... connected * Connected to localhost (127.0.0.1) port 8080 (#0) > PUT / HTTP/1.1 > User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.13.1.0 > zlib/1.2.3 libidn/1.18 libssh2/1.2.2 > Host: localhost:8080 > Accept: */* > Transfer-Encoding: chunked > Content-Type: application/binary > > 190 * Empty reply from server * Connection #0 to host localhost left intact curl: (52) Empty reply from server * Closing connection #0 -------------- Here's my test script: [spierce@memory chunked]$ cat app.py import uwsgi def application(e, sr): while True: msg = uwsgi.chunked_read(0) if msg: print len(msg) if not msg: sr('200 OK', [('Content-Length', '0')] ) return [] ---- UWSGI output: [spierce@memory chunked]$ uwsgi --wsgi-file app.py --http-manage-expect --http 127.0.0.1:8080 --http-raw-body *** Starting uWSGI 1.9.13 (64bit) on [Wed Jul 3 20:08:18 2013] *** compiled with version: 4.4.7 20120313 (Red Hat 4.4.7-3) on 25 June 2013 16:37:29 os: Linux-2.6.32-279.2.1.el6.x86_64 #1 SMP Fri Jul 20 01:55:29 UTC 2012 nodename: memory.verifyle.local machine: x86_64 clock source: unix pcre jit disabled detected number of CPU cores: 2 current working directory: /home/spierce/chunked detected binary path: /usr/sbin/uwsgi *** WARNING: you are running uWSGI without its master process manager *** your processes number limit is 1024 your memory page size is 4096 bytes detected max file descriptor number: 1024 lock engine: pthread robust mutexes uWSGI http bound on 127.0.0.1:8080 fd 4 spawned uWSGI http 1 (pid: 383) uwsgi socket 0 bound to TCP address 127.0.0.1:41078 (port auto-assigned) fd 3 Python version: 2.6.6 (r266:84292, Feb 22 2013, 00:00:18) [GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] *** Python threads support is disabled. You can enable it with --enable-threads *** Python main interpreter initialized at 0x75bdb0 initialized Perl 5.10.1 main interpreter at 0x7e80a0 your server socket listen backlog is limited to 100 connections your mercy for graceful operations on workers is 60 seconds mapped 72768 bytes (71 KB) for 1 cores *** Operational MODE: single process *** WSGI app 0 (mountpoint='') ready in 0 seconds on interpreter 0x75bdb0 pid: 382 (default app) *** uWSGI is running in multiple interpreter mode *** spawned uWSGI worker 1 (and the only) (pid: 382, cores: 1) Traceback (most recent call last): File "app.py", line 4, in application msg = uwsgi.chunked_read(0) IOError: unable to receive chunked part [pid: 382|app: 0|req: 1/1] 127.0.0.1 () {32 vars in 461 bytes} [Wed Jul 3 20:08:22 2013] PUT / => generated 0 bytes in 4004 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0) _______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
