Commit 5df4cef9 authored by Denis Bilenko's avatar Denis Bilenko

Fix #303: 'requestline' AttributeError in pywsgi

Close #304: original PR by Neil Chintomby.
parent d54a13df
......@@ -291,21 +291,22 @@ class WSGIHandler(object):
return
try:
raw_requestline = self.read_requestline()
self.requestline = self.read_requestline()
except socket.error:
# "Connection reset by peer" or other socket errors aren't interesting here
return
if not raw_requestline:
if not self.requestline:
return
self.response_length = 0
if len(raw_requestline) >= MAX_REQUEST_LINE:
if len(self.requestline) >= MAX_REQUEST_LINE:
return ('414', _REQUEST_TOO_LONG_RESPONSE)
try:
if not self.read_request(raw_requestline):
# for compatibility with older versions of pywsgi, we pass self.requestline as an argument there
if not self.read_request(self.requestline):
return ('400', _BAD_REQUEST_RESPONSE)
except Exception:
ex = sys.exc_info()[1]
......@@ -473,7 +474,7 @@ class WSGIHandler(object):
return '%s - - [%s] "%s" %s %s %s' % (
self.client_address[0],
now,
self.requestline,
getattr(self, 'requestline', ''),
(getattr(self, 'status', None) or '000').split()[0],
length,
delta)
......
......@@ -1218,6 +1218,20 @@ class TestInputRaw(greentest.BaseTestCase):
i = self.make_input("2\r\n1", chunked_input=True)
self.assertRaises(IOError, i.readline)
class Test414(TestCase):
@staticmethod
def application(env, start_response):
raise AssertionError('should not get there')
def test(self):
fd = self.makefile()
longline = 'x' * 20000
fd.write('''GET /%s HTTP/1.0\r\nHello: world\r\n\r\n''' % longline)
read_http(fd, code=414, version='1.0')
del CommonTests
if __name__ == '__main__':
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment