Search code examples
pythonproxyaiohttp

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?


Solution

  • 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.