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
self.assertTrue(host_re.match(response.body), response.body)
-class CreateAsyncHTTPClientTestCase(AsyncTestCase, LogTrapTestCase):
+class SaveAsyncHTTPClientConfigurationTestCase(AsyncTestCase, LogTrapTestCase):
def setUp(self):
- super(CreateAsyncHTTPClientTestCase, self).setUp()
+ super(SaveAsyncHTTPClientConfigurationTestCase, self).setUp()
self.saved = AsyncHTTPClient._save_configuration()
def tearDown(self):
AsyncHTTPClient._restore_configuration(self.saved)
- super(CreateAsyncHTTPClientTestCase, self).tearDown()
+ super(SaveAsyncHTTPClientConfigurationTestCase, self).tearDown()
+
+class CreateAsyncHTTPClientTestCase(SaveAsyncHTTPClientConfigurationTestCase):
def test_max_clients(self):
# The max_clients argument is tricky because it was originally
# allowed to be passed positionally; newer arguments are keyword-only.
with closing(AsyncHTTPClient(
self.io_loop, max_clients=14, force_instance=True)) as client:
self.assertEqual(client.max_clients, 14)
+
+
+class HTTP100ContinueTestCase(SaveAsyncHTTPClientConfigurationTestCase):
+ def respond_100(self, request):
+ self.request = request
+ self.request.connection.stream.write("HTTP/1.1 100 CONTINUE\r\n\r\n", self.respond_200)
+
+ def respond_200(self):
+ self.request.connection.stream.write("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.assertEquals(res.body, 'A')