Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge remote-tracking branch 'bergundy/upstream'

  • Loading branch information...
commit 986f415ec22a33ef6dfa9a59bf8ad85d2ea6a932 2 parents 4daeaeb + 0e1863c
@bdarnell bdarnell authored
View
8 tornado/simple_httpclient.py
@@ -333,7 +333,13 @@ def _on_headers(self, data):
first_line, _, header_data = data.partition("\n")
match = re.match("HTTP/1.[01] ([0-9]+)", first_line)
assert match
- self.code = int(match.group(1))
+ code = int(match.group(1))
+ if 100 <= code < 200:
+ self.stream.read_until_regex(b("\r?\n\r?\n"), self._on_headers)
+ return
+ else:
+ self.code = code
+
self.headers = HTTPHeaders.parse(header_data)
if "Content-Length" in self.headers:
View
22 tornado/test/simple_httpclient_test.py
@@ -12,7 +12,7 @@
from tornado.ioloop import IOLoop
from tornado.simple_httpclient import SimpleAsyncHTTPClient, _DEFAULT_CA_CERTS
from tornado.test.httpclient_test import HTTPClientCommonTestCase, ChunkHandler, CountdownHandler, HelloWorldHandler
-from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, LogTrapTestCase
+from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, LogTrapTestCase, get_unused_port
from tornado.util import b
from tornado.web import RequestHandler, Application, asynchronous, url
@@ -319,3 +319,23 @@ def test_max_clients(self):
with closing(AsyncHTTPClient(
self.io_loop, max_clients=14, force_instance=True)) as client:
self.assertEqual(client.max_clients, 14)
+
+
+class HTTP100ContinueTestCase(AsyncTestCase, LogTrapTestCase):
+ def respond_100(self, request):
+ self.request = request
+ self.request.connection.stream.write(b("HTTP/1.1 100 CONTINUE\r\n\r\n"), self.respond_200)
+
+ def respond_200(self):
+ self.request.connection.stream.write(b("HTTP/1.1 200 OK\r\nContent-Length: 1\r\n\r\nA"))
+
+ def test_100_continue(self):
+ from tornado.httpserver import HTTPServer
+
+ port = get_unused_port()
+ server = HTTPServer(self.respond_100, io_loop = self.io_loop)
+ server.listen(port)
+ client = SimpleAsyncHTTPClient(io_loop = self.io_loop)
+ client.fetch('http://localhost:%d/' % port, self.stop)
+ res = self.wait()
+ self.assertEqual(res.body, b('A'))
Please sign in to comment.
Something went wrong with that request. Please try again.