From 6ec9165b4bf4bc962b2b76265c20a4d62658d140 Mon Sep 17 00:00:00 2001 From: Ryan Williams Date: Tue, 5 Jan 2010 21:13:47 -0800 Subject: [PATCH] Updated wsgi_test to pass. --- tests/wsgi_test.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/tests/wsgi_test.py b/tests/wsgi_test.py index cde6ee1..2b3d65d 100644 --- a/tests/wsgi_test.py +++ b/tests/wsgi_test.py @@ -596,16 +596,30 @@ class TestHttpd(LimitedTestCase): return [text] self.site.application = wsgi_app sock = api.connect_tcp(('localhost', self.port)) - fd = sock.makeGreenFile() + fd = sock.makefile() fd.write('PUT / HTTP/1.1\r\nHost: localhost\r\nContent-length: 1025\r\nExpect: 100-continue\r\n\r\n') - result = fd.readuntil('\r\n\r\n') - self.assert_(result.startswith('HTTP/1.1 417 Expectation Failed')) - self.assertEquals(fd.read(7), 'failure') + fd.flush() + response_line, headers, body = read_http(sock) + self.assert_(response_line.startswith('HTTP/1.1 417 Expectation Failed')) + self.assertEquals(body, 'failure') fd.write('PUT / HTTP/1.1\r\nHost: localhost\r\nContent-length: 7\r\nExpect: 100-continue\r\n\r\ntesting') - result = fd.readuntil('\r\n\r\n') - self.assert_(result.startswith('HTTP/1.1 100 Continue')) - result = fd.readuntil('\r\n\r\n') - self.assert_(result.startswith('HTTP/1.1 200 OK')) + fd.flush() + header_lines = [] + while True: + line = fd.readline() + if line == '\r\n': + break + else: + header_lines.append(line) + self.assert_(header_lines[0].startswith('HTTP/1.1 100 Continue')) + header_lines = [] + while True: + line = fd.readline() + if line == '\r\n': + break + else: + header_lines.append(line) + self.assert_(header_lines[0].startswith('HTTP/1.1 200 OK')) self.assertEquals(fd.read(7), 'testing') fd.close()