baidao
baidao

Reputation: 503

How do you utilize proxy support with the python aiohttp framework

Does os.environ['http_proxy'] still work? And how to utilize proxy per request?

Upvotes: 2

Views: 833

Answers (1)

Andrew Svetlov
Andrew Svetlov

Reputation: 17366

HTTP Proxy support has added to aiohttp in the recent 0.7.3 release. It doesn't use os.environ['http_proxy'] and probably will never do.

To specify proxy for request you can use code like this:

connector = aiohttp.ProxyConnector(proxies={'http': 'http://proxyaddr:8118'})
response = yield from aiohttp.request('get', 'http://python.org/', connector=connector)

HTTPS proxies are not supported yet, sorry.

Perhaps we add the feature very soon: we need for HTTPS proxies for our business tasks.

Upvotes: 1

Related Questions