Commit f053bc9b authored by Ralf Schmitt's avatar Ralf Schmitt

port eventlet tests for 'HTTP/1.1 100 Continue'

--HG--
extra : transplant_source : %D8%1D%EAt%BBLJD%FB%1B%B9%1E%AF%7Co%A4%1D%5C%E7%CC
parent 55a476ec
......@@ -150,6 +150,8 @@ class Response(object):
self.assertReason(reason)
if version is not None:
self.assertVersion(version)
if self.code == 100:
return self
try:
if 'chunked' in headers.get('Transfer-Encoding', ''):
if CONTENT_LENGTH in headers:
......@@ -795,6 +797,28 @@ class ChunkedInputTests(TestCase):
assert not got_signal, "caught alarm signal. infinite loop detected."
class Expect100ContinueTests(TestCase):
validator = None
def application(self, environ, start_response):
if int(environ['CONTENT_LENGTH']) > 1024:
start_response('417 Expectation Failed', [('Content-Length', '7'), ('Content-Type', 'text/plain')])
return ['failure']
else:
text = environ['wsgi.input'].read()
start_response('200 OK', [('Content-Length', str(len(text))), ('Content-Type', 'text/plain')])
return [text]
def test_continue(self):
fd = self.connect().makefile(bufsize=1)
fd.write('PUT / HTTP/1.1\r\nHost: localhost\r\nContent-length: 1025\r\nExpect: 100-continue\r\n\r\n')
read_http(fd, code=417, body="failure")
fd.write('PUT / HTTP/1.1\r\nHost: localhost\r\nContent-length: 7\r\nExpect: 100-continue\r\n\r\ntesting')
read_http(fd, code=100)
read_http(fd, body="testing")
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