Added size parameter to wsgi.py's readline to be compatible with webob.

This commit is contained in:
Ryan Williams
2009-10-19 13:32:17 -05:00
parent 21ea45d446
commit ff512ff1c2
3 changed files with 24 additions and 3 deletions

View File

@@ -27,3 +27,4 @@ Thanks To
* 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
* Ralf Schmitt, for wsgi/webob incompatibility bug report and suggested fix

View File

@@ -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):

View File

@@ -405,6 +405,26 @@ class TestHttpd(LimitedTestCase):
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__':