websocket_connect 如何通过配置的AsyncHTTPClient 指定代理?
websocket_connect how to pass configured AsyncHTTPClient so could specify proxy?
使用龙卷风==4.5.3 python==3.5.2
似乎可以通过
AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
但是在哪里?
@tornado.gen.coroutine
def open(self, proxy=None):
proxy_host, proxy_port, proxy_username, proxy_password = parse_proxy_dict(proxy)
connection_request = HTTPRequest(
url=self.URL, proxy_host=proxy_host, proxy_port=proxy_port,
proxy_username=proxy_username, proxy_password=proxy_password)
try:
self.connection = yield websocket_connect(connection_request)
self.on_open()
while True:
msg = yield self.connection.read_message()
if msg is None:
self.on_close()
break
yield self.on_message(msg)
except (Exception, KeyboardInterrupt, SystemExit) as error:
self.on_error(error)
ws on_error: proxy_host not supported
websocket_connect
只使用了 AsyncHTTPClient
的部分实现,因此不受 AsyncHTTPClient.configure
的影响。特别是,它不能使用 curl,只能使用不支持代理的 tornado.simple_httpclient
。
使用龙卷风==4.5.3 python==3.5.2
似乎可以通过
AsyncHTTPClient.configure("tornado.curl_httpclient.CurlAsyncHTTPClient")
但是在哪里?
@tornado.gen.coroutine
def open(self, proxy=None):
proxy_host, proxy_port, proxy_username, proxy_password = parse_proxy_dict(proxy)
connection_request = HTTPRequest(
url=self.URL, proxy_host=proxy_host, proxy_port=proxy_port,
proxy_username=proxy_username, proxy_password=proxy_password)
try:
self.connection = yield websocket_connect(connection_request)
self.on_open()
while True:
msg = yield self.connection.read_message()
if msg is None:
self.on_close()
break
yield self.on_message(msg)
except (Exception, KeyboardInterrupt, SystemExit) as error:
self.on_error(error)
ws on_error: proxy_host not supported
websocket_connect
只使用了 AsyncHTTPClient
的部分实现,因此不受 AsyncHTTPClient.configure
的影响。特别是,它不能使用 curl,只能使用不支持代理的 tornado.simple_httpclient
。