from tornado.simple_httpclient import SimpleAsyncHTTPClient, _DEFAULT_CA_CERTS
from tornado.test.httpclient_test import ChunkHandler, CountdownHandler, HelloWorldHandler
from tornado.test import httpclient_test
-from tornado.testing import AsyncHTTPTestCase, AsyncTestCase, bind_unused_port, ExpectLog
+from tornado.testing import AsyncHTTPTestCase, AsyncHTTPSTestCase, AsyncTestCase, bind_unused_port, ExpectLog
from tornado.test.util import unittest, skipOnTravis
from tornado.web import RequestHandler, Application, asynchronous, url
self.write(self.request.headers["Host"])
-class SimpleHTTPClientTestCase(AsyncHTTPTestCase):
- def setUp(self):
- super(SimpleHTTPClientTestCase, self).setUp()
- self.http_client = SimpleAsyncHTTPClient(self.io_loop)
-
+class SimpleHTTPClientTestMixin(object):
def get_app(self):
# callable objects to finish pending /trigger requests
self.triggers = collections.deque()
SimpleAsyncHTTPClient(io_loop2))
def test_connection_limit(self):
- client = SimpleAsyncHTTPClient(self.io_loop, max_clients=2,
- force_instance=True)
+ client = self.create_client(max_clients=2)
self.assertEqual(client.max_clients, 2)
seen = []
# Send 4 requests. Two can be sent immediately, while the others
def test_redirect_connection_limit(self):
# following redirects should not consume additional connections
- client = SimpleAsyncHTTPClient(self.io_loop, max_clients=1,
- force_instance=True)
+ client = self.create_client(max_clients=1)
client.fetch(self.get_url('/countdown/3'), self.stop,
max_redirects=3)
response = self.wait()
response.error)
+class SimpleHTTPClientTestCase(SimpleHTTPClientTestMixin, AsyncHTTPTestCase):
+ def setUp(self):
+ super(SimpleHTTPClientTestCase, self).setUp()
+ self.http_client = self.create_client()
+
+ def create_client(self, **kwargs):
+ return SimpleAsyncHTTPClient(self.io_loop, force_instance=True,
+ **kwargs)
+
+
+class SimpleHTTPSClientTestCase(SimpleHTTPClientTestMixin, AsyncHTTPSTestCase):
+ def setUp(self):
+ super(SimpleHTTPSClientTestCase, self).setUp()
+ self.http_client = self.create_client()
+
+ def create_client(self, **kwargs):
+ return SimpleAsyncHTTPClient(self.io_loop, force_instance=True,
+ defaults=dict(validate_cert=False),
+ **kwargs)
+
+
class CreateAsyncHTTPClientTestCase(AsyncTestCase):
def setUp(self):
super(CreateAsyncHTTPClientTestCase, self).setUp()