本文整理汇总了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.