Updated wsgi_test to pass.

This commit is contained in:
Ryan Williams
2010-01-05 21:13:47 -08:00
parent e97fffeb50
commit 6ec9165b4b

View File

@@ -596,16 +596,30 @@ class TestHttpd(LimitedTestCase):
return [text] return [text]
self.site.application = wsgi_app self.site.application = wsgi_app
sock = api.connect_tcp(('localhost', self.port)) 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') 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') fd.flush()
self.assert_(result.startswith('HTTP/1.1 417 Expectation Failed')) response_line, headers, body = read_http(sock)
self.assertEquals(fd.read(7), 'failure') 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') 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') fd.flush()
self.assert_(result.startswith('HTTP/1.1 100 Continue')) header_lines = []
result = fd.readuntil('\r\n\r\n') while True:
self.assert_(result.startswith('HTTP/1.1 200 OK')) 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') self.assertEquals(fd.read(7), 'testing')
fd.close() fd.close()