|
12 | 12 | from tornado.ioloop import IOLoop
|
13 | 13 | from tornado.simple_httpclient import SimpleAsyncHTTPClient, _DEFAULT_CA_CERTS
|
14 | 14 | from tornado.test.httpclient_test import HTTPClientCommonTestCase, ChunkHandler, CountdownHandler, HelloWorldHandler
|
15 |
| -from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, LogTrapTestCase |
| 15 | +from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, LogTrapTestCase, get_unused_port |
16 | 16 | from tornado.util import b
|
17 | 17 | from tornado.web import RequestHandler, Application, asynchronous, url
|
18 | 18 |
|
@@ -319,3 +319,23 @@ def test_max_clients(self):
|
319 | 319 | with closing(AsyncHTTPClient(
|
320 | 320 | self.io_loop, max_clients=14, force_instance=True)) as client:
|
321 | 321 | self.assertEqual(client.max_clients, 14)
|
| 322 | + |
| 323 | + |
| 324 | +class HTTP100ContinueTestCase(AsyncTestCase, LogTrapTestCase): |
| 325 | + def respond_100(self, request): |
| 326 | + self.request = request |
| 327 | + self.request.connection.stream.write(b("HTTP/1.1 100 CONTINUE\r\n\r\n"), self.respond_200) |
| 328 | + |
| 329 | + def respond_200(self): |
| 330 | + self.request.connection.stream.write(b("HTTP/1.1 200 OK\r\nContent-Length: 1\r\n\r\nA")) |
| 331 | + |
| 332 | + def test_100_continue(self): |
| 333 | + from tornado.httpserver import HTTPServer |
| 334 | + |
| 335 | + port = get_unused_port() |
| 336 | + server = HTTPServer(self.respond_100, io_loop = self.io_loop) |
| 337 | + server.listen(port) |
| 338 | + client = SimpleAsyncHTTPClient(io_loop = self.io_loop) |
| 339 | + client.fetch('http://localhost:%d/' % port, self.stop) |
| 340 | + res = self.wait() |
| 341 | + self.assertEqual(res.body, b('A')) |
0 commit comments