diff --git a/CHANGES/7325.doc b/CHANGES/7325.doc new file mode 100644 index 00000000000..c0a08541d30 --- /dev/null +++ b/CHANGES/7325.doc @@ -0,0 +1 @@ +Complete trust_env parameter description to honor wss_proxy, ws_proxy or no_proxy env diff --git a/docs/client_advanced.rst b/docs/client_advanced.rst index 5cb71a959d1..35229cb6381 100644 --- a/docs/client_advanced.rst +++ b/docs/client_advanced.rst @@ -561,6 +561,8 @@ DER with e.g:: to :class:`TCPConnector` as default, the value from :meth:`ClientSession.get` and others override default. +.. _aiohttp-client-proxy-support: + Proxy support ------------- @@ -592,14 +594,18 @@ Authentication credentials can be passed in proxy URL:: Contrary to the ``requests`` library, it won't read environment variables by default. But you can do so by passing ``trust_env=True`` into :class:`aiohttp.ClientSession` -constructor for extracting proxy configuration from -*HTTP_PROXY*, *HTTPS_PROXY*, *WS_PROXY* or *WSS_PROXY* *environment -variables* (all are case insensitive):: +constructor.:: async with aiohttp.ClientSession(trust_env=True) as session: async with session.get("http://python.org") as resp: print(resp.status) +.. note:: + aiohttp uses :func:`urllib.request.getproxies` + for reading the proxy configuration (e.g. from the *HTTP_PROXY* etc. environment variables) and applies them for the *HTTP*, *HTTPS*, *WS* and *WSS* schemes. + + Hosts defined in ``no_proxy`` will bypass the proxy. + Proxy credentials are given from ``~/.netrc`` file if present (see :class:`aiohttp.ClientSession` for more details). diff --git a/docs/client_reference.rst b/docs/client_reference.rst index 9d88cb85a83..c33f2ca7bee 100644 --- a/docs/client_reference.rst +++ b/docs/client_reference.rst @@ -173,9 +173,9 @@ The client session supports the context manager protocol for self closing. .. versionadded:: 3.7 - :param bool trust_env: Get proxies information from *HTTP_PROXY* / - *HTTPS_PROXY* environment variables if the parameter is ``True`` - (``False`` by default). + :param bool trust_env: Trust environment settings for proxy configuration if the parameter + is ``True`` (``False`` by default). See :ref:`aiohttp-client-proxy-support` for + more information. Get proxy credentials from ``~/.netrc`` file if present. @@ -321,8 +321,9 @@ The client session supports the context manager protocol for self closing. .. attribute:: trust_env - Should get proxies information from HTTP_PROXY / HTTPS_PROXY environment - variables or ~/.netrc file if present + Trust environment settings for proxy configuration + or ~/.netrc file if present. See :ref:`aiohttp-client-proxy-support` for + more information. :class:`bool` default is ``False``