From ff512ff1c2252a1f2e8437ddb14a4b910dd9adad Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Mon, 19 Oct 2009 13:32:17 -0500 Subject: [PATCH] Added size parameter to wsgi.py's readline to be compatible with webob. --- AUTHORS | 3 ++- eventlet/wsgi.py | 2 +- tests/wsgi_test.py | 22 +++++++++++++++++++++- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/AUTHORS b/AUTHORS index 6d56513..559e5c0 100644 --- a/AUTHORS +++ b/AUTHORS @@ -26,4 +26,5 @@ Thanks To * Marcus Cavanaugh, for test case code that has been incredibly useful in tracking down bugs * Brian Brunswick, for many helpful questions and suggestions on the mailing list * Cesar Alaniz, for uncovering bugs of great import -* the grugq, for contributing patches, suggestions, and use cases \ No newline at end of file +* the grugq, for contributing patches, suggestions, and use cases +* Ralf Schmitt, for wsgi/webob incompatibility bug report and suggested fix \ No newline at end of file diff --git a/eventlet/wsgi.py b/eventlet/wsgi.py index 4521dcd..31af034 100644 --- a/eventlet/wsgi.py +++ b/eventlet/wsgi.py @@ -107,7 +107,7 @@ class Input(object): return self._chunked_read(self.rfile, length) return self._do_read(self.rfile.read, length) - def readline(self): + def readline(self, size=None): return self._do_read(self.rfile.readline) def readlines(self, hint=None): diff --git a/tests/wsgi_test.py b/tests/wsgi_test.py index 33241d0..e50f7a0 100644 --- a/tests/wsgi_test.py +++ b/tests/wsgi_test.py @@ -404,7 +404,27 @@ class TestHttpd(LimitedTestCase): fd.write('GET / HTTP/1.0\r\nHost: localhost\r\nConnection: keep-alive\r\n\r\n') self.assert_('connection: keep-alive' in fd.readuntil('\r\n\r\n').lower()) - + + def test_019_fieldstorage_compat(self): + def use_fieldstorage(environ, start_response): + import cgi + fs = cgi.FieldStorage(fp=environ['wsgi.input'], + environ=environ) + start_response('200 OK', [('Content-type', 'text/plain')]) + return ['hello!'] + + self.site.application = use_fieldstorage + sock = api.connect_tcp( + ('localhost', self.port)) + + fd = sock.makeGreenFile() + fd.write('POST / HTTP/1.1\r\n' + 'Host: localhost\r\n' + 'Connection: close\r\n' + 'Transfer-Encoding: chunked\r\n\r\n' + '2\r\noh\r\n' + '4\r\n hai\r\n0\r\n\r\n') + self.assert_('hello!' in fd.read()) if __name__ == '__main__':