Hi, To make it easier to reproduce the bug, I just rewrite the test files,
you can clone the hg repo here.
https://bitbucket.org/victorlin/uwsgi_bug/
To run the uwsgi, you can type
uwsgi --yaml uwsgi.yaml
You need to include the nginx config, too
include /path/to/uwsgi_bug/*.nx.conf;
With the running wsgi app under uwsgi with nginx, you can then run
send_req.py
It reads my_req.txt and send to the nginx server. As result, you can see
Traceback (most recent call last):
File "./wsgi.py", line 5, in application
print req.str_POST
File "/home/nowin/lib/python2.7/webob/request.py", line 528, in str_POST
return self._str_POST
File "/home/nowin/lib/python2.7/webob/request.py", line 558, in _str_POST
keep_blank_values=True)
File "/usr/local/lib/python2.7/cgi.py", line 508, in __init__
self.read_multi(environ, keep_blank_values, strict_parsing)
File "/usr/local/lib/python2.7/cgi.py", line 632, in read_multi
environ, keep_blank_values, strict_parsing)
File "/usr/local/lib/python2.7/cgi.py", line 510, in __init__
self.read_single()
File "/usr/local/lib/python2.7/cgi.py", line 647, in read_single
self.read_lines()
File "/usr/local/lib/python2.7/cgi.py", line 669, in read_lines
self.read_lines_to_outerboundary()
File "/usr/local/lib/python2.7/cgi.py", line 697, in
read_lines_to_outerboundary
line = self.fp.readline(1<<16)
File "/home/nowin/lib/python2.7/webob/request.py", line 1292, in readline
self._check_disconnect()
File "/home/nowin/lib/python2.7/webob/request.py", line 1311, in
_check_disconnect
+ "(%d more bytes were expected)" % self.remaining
webob.request.DisconnectionError: The client disconnected while sending the
POST/PUT body (336 more bytes were expected)
If you want to see the missing \n ouput, just replace "If True:" in wsgi.py
with "If False:", the output should be
'------WebKitFormBoundaryAQRPBQgGHAhs61hx\r'
'Content-Disposition: form-data; name="image"; filename="log.txt"\r\n'
'Content-Type: text/plain\r\n'
'\r\n'
'hello\r\n'
'------WebKitFormBoundaryAQRPBQgGHAhs61hx\r\n'
'Content-Disposition: form-data; name="name"\r\n'
'\r\n'
'\r\n'
'------WebKitFormBoundaryAQRPBQgGHAhs61hx\r\n'
'Content-Disposition: form-data; name="submit"\r\n'
'\r\n'
'Submit\r\n'
'------WebKitFormBoundaryAQRPBQgGHAhs61hx--\r\n'
As you can see the tail \n is missing in first line.
The versions I have tested are uWSGI 0.9.9.1 and uWSGI 0.9.8. The version of
Nginx is 1.0.4. If you need further information, just tell me. I hope this
could be helpful for improving uWSGI :)
Thanks.
Victor Lin.
2011/9/5 Roberto De Ioris <[email protected]>
>
> > I did encounter same problem recently. I have inspected how it works, and
> > eventually understand why it goes wrong. It's not a bug of webob, it's a
> > bug
> > of uWSGI. I did write a simple wsgi app to reproduce the issue,
> >
> > def application(environ, start_response):
> > input = environ['wsgi.input']
> > while True:
> > line = input.readline()
> > if not line:
> > break
> > print repr(line)
> >
> > run it with uwsgi and submit a multipart/form-data from. Following lines
> > are
> > the output
> >
> > '-----------------------------256672629917035\r'
> > 'Content-Disposition: form-data; name="title"\r\n'
> > '\r\n'
> >
> >
>
> Another thing, are you sure this line is not from the very end of the
> output ? (i am testing for the first line)
>
> If it is so, it is normal to have it not ending with \n if the buffer is
> not big enough to hold a line.
>
> As i have wrote to Ian, the readline() in webob use a 64k buffer, so if i
> send a 64k+1 sequence of 0, the check will fail again. uWSGI uses 1k
> buffer for lines, this violates the webob expectations as well as a 64k
> buffer.
>
> IMHO the check for \n should be avoided, as the python specs says that if
> you pass a hint to readline() you have to not rely on \n at the end.
>
> If webob removes the hint, uWSGI will fail again (too little buffer) but
> you will ends allocating an enormous memory chunks (think about a 2gb file
> full of 0).
>
> --
> Roberto De Ioris
> http://unbit.it
> _______________________________________________
> uWSGI mailing list
> [email protected]
> http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi
>
_______________________________________________
uWSGI mailing list
[email protected]
http://lists.unbit.it/cgi-bin/mailman/listinfo/uwsgi