On Jun 26, 2013 12:40 PM, "Stephen Pierce" <[email protected]> wrote: > > Nice work, Roberto! I was thinking of doing something very similar because I need to accept an HTTP POST request with Transfer-Encoding: chunked. I was also thinking I might have to resort to Twisted (bleh). Imagine my surprise when I found out that you already did it! > > So, I've been trying to get these new functions working, but I'm having problems. I'm running my proof-of-concept app on port 2000, and I connect to it using a modified version of your send application. I got annoyed with the EOFError exception. :-) > > When I connect, I can see from my sniffer that the sending application appears to be doing its job. Each input line is sent as a chunk, and I get TCP-ACK back for each one. However, the web application just sits until the timeout, then gives me the timeout exception. > > What am I doing wrong? > > Steve > > [spierce@memory chunked]$ cat send.py > import socket > import sys > > s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) > > (addr, port) = sys.argv[1].split(':') > s.connect((addr, int(port))) > > s.send("POST /send HTTP/1.1\r\n") > s.send("Transfer-Encoding: chunked\r\n\r\n") > > try: > while True: > msg = raw_input("msg >> ") > s.send("%X\r\n%s\r\n" % (len(msg), msg)) > except EOFError: > print > pass > > Here's the application: > > [spierce@memory chunked]$ cat app1.py > import uwsgi > def application(e, sr): > while True: > msg = uwsgi.chunked_read(10) > if msg: print "core %d" % e['uwsgi.core'], msg > > Here's how I start it: > > [spierce@memory chunked]$ uwsgi --wsgi-file app1.py --http 127.0.0.1:2000 > *** Starting uWSGI 1.9.13 (64bit) on [Wed Jun 26 10:29:27 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:2000 fd 4 > spawned uWSGI http 1 (pid: 15559) > uwsgi socket 0 bound to TCP address 127.0.0.1:50095 (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 0x1e3fd00 > initialized Perl 5.10.1 main interpreter at 0x1ecc330 > 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 0x1e3fd00 pid: 15558 (default app) > *** uWSGI is running in multiple interpreter mode *** > spawned uWSGI worker 1 (and the only) (pid: 15558, cores: 1) > > Here's the error: > > Traceback (most recent call last): > File "app1.py", line 4, in application > msg = uwsgi.chunked_read(10) > IOError: unable to receive chunked part > [pid: 15558|app: 0|req: 1/1] 127.0.0.1 () {24 vars in 270 bytes} [Wed Jun 26 10:29:30 2013] POST /send => generated 0 bytes in 4360 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
Try --http-socket instead, or add --http-raw-body... I believe the implicit http server spawned by --http is buffering. C Anthony [mobile]
_______________________________________________ uWSGI mailing list [email protected] http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
