本文整理匯總了Python中tornado.curl_httpclient.CurlAsyncHTTPClient方法的典型用法代碼示例。如果您正苦於以下問題:Python curl_httpclient.CurlAsyncHTTPClient方法的具體用法?Python curl_httpclient.CurlAsyncHTTPClient怎麽用?Python curl_httpclient.CurlAsyncHTTPClient使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類tornado.curl_httpclient
的用法示例。
在下文中一共展示了curl_httpclient.CurlAsyncHTTPClient方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: main
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def main():
parse_command_line()
app = Application([('/', ChunkHandler)])
app.listen(options.port, address='127.0.0.1')
def callback(response):
response.rethrow()
assert len(response.body) == (options.num_chunks * options.chunk_size)
logging.warning("fetch completed in %s seconds", response.request_time)
IOLoop.current().stop()
logging.warning("Starting fetch with curl client")
curl_client = CurlAsyncHTTPClient()
curl_client.fetch('http://localhost:%d/' % options.port,
callback=callback)
IOLoop.current().start()
logging.warning("Starting fetch with simple client")
simple_client = SimpleAsyncHTTPClient()
simple_client.fetch('http://localhost:%d/' % options.port,
callback=callback)
IOLoop.current().start()
示例2: main
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def main():
parse_command_line()
app = Application([('/', ChunkHandler)])
app.listen(options.port, address='127.0.0.1')
def callback(response):
response.rethrow()
assert len(response.body) == (options.num_chunks * options.chunk_size)
logging.warning("fetch completed in %s seconds", response.request_time)
IOLoop.instance().stop()
logging.warning("Starting fetch with curl client")
curl_client = CurlAsyncHTTPClient()
curl_client.fetch('http://localhost:%d/' % options.port,
callback=callback)
IOLoop.instance().start()
logging.warning("Starting fetch with simple client")
simple_client = SimpleAsyncHTTPClient()
simple_client.fetch('http://localhost:%d/' % options.port,
callback=callback)
IOLoop.instance().start()
示例3: _tornado
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def _tornado():
try:
import tornado.simple_httpclient as simple
except ImportError:
pass
else:
new_fetch_impl = traced_fetch_impl(
_SimpleAsyncHTTPClient_fetch_impl
)
yield simple.SimpleAsyncHTTPClient, 'fetch_impl', new_fetch_impl
try:
import tornado.curl_httpclient as curl
except ImportError:
pass
else:
new_fetch_impl = traced_fetch_impl(
_CurlAsyncHTTPClient_fetch_impl
)
yield curl.CurlAsyncHTTPClient, 'fetch_impl', new_fetch_impl
示例4: reset_patchers
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def reset_patchers():
try:
import tornado.simple_httpclient as simple
except ImportError:
pass
else:
setattr(
simple.SimpleAsyncHTTPClient,
'fetch_impl',
_SimpleAsyncHTTPClient_fetch_impl,
)
try:
import tornado.curl_httpclient as curl
except ImportError:
pass
else:
setattr(
curl.CurlAsyncHTTPClient,
'fetch_impl',
_CurlAsyncHTTPClient_fetch_impl,
)
示例5: get_http_client
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def get_http_client(self):
client = CurlAsyncHTTPClient(io_loop=self.io_loop,
defaults=dict(allow_ipv6=False))
# make sure AsyncHTTPClient magic doesn't give us the wrong class
self.assertTrue(isinstance(client, CurlAsyncHTTPClient))
return client
示例6: setUp
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def setUp(self):
super(CurlHTTPClientTestCase, self).setUp()
self.http_client = CurlAsyncHTTPClient(self.io_loop,
defaults=dict(allow_ipv6=False))
示例7: get_http_client
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def get_http_client(self):
client = CurlAsyncHTTPClient(defaults=dict(allow_ipv6=False))
# make sure AsyncHTTPClient magic doesn't give us the wrong class
self.assertTrue(isinstance(client, CurlAsyncHTTPClient))
return client
示例8: create_client
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def create_client(self, **kwargs):
return CurlAsyncHTTPClient(
force_instance=True, defaults=dict(allow_ipv6=False), **kwargs
)
示例9: get_http_client
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def get_http_client(self):
client = CurlAsyncHTTPClient(io_loop=self.io_loop)
# make sure AsyncHTTPClient magic doesn't give us the wrong class
self.assertTrue(isinstance(client, CurlAsyncHTTPClient))
return client
示例10: setUp
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def setUp(self):
super(CurlHTTPClientTestCase, self).setUp()
self.http_client = CurlAsyncHTTPClient(self.io_loop)
示例11: create_client
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def create_client(self, **kwargs):
return CurlAsyncHTTPClient(force_instance=True,
defaults=dict(allow_ipv6=False),
**kwargs)
示例12: get_http_client
# 需要導入模塊: from tornado import curl_httpclient [as 別名]
# 或者: from tornado.curl_httpclient import CurlAsyncHTTPClient [as 別名]
def get_http_client(self):
client = CurlAsyncHTTPClient(io_loop=self.io_loop)
# make sure AsyncHTTPClient magic doesn't give us the wrong class
self.assertTrue(isinstance(client, CurlAsyncHTTPClient))
return client
# Remove the base class from our namespace so the unittest module doesn't
# try to run it again.