From 497cfc3462e69d6bdbf1f5d06c4f69751c9cfe3a Mon Sep 17 00:00:00 2001 From: ahmad ali <2k22.cse.2213393@gmail.com> Date: Tue, 27 Jan 2026 07:48:29 +0530 Subject: [PATCH] docs: clarify gzip decompression behavior when using stream=True --- docs/user/advanced.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/docs/user/advanced.rst b/docs/user/advanced.rst index 2ff0c7dfbf..2e8ddd9ebe 100644 --- a/docs/user/advanced.rst +++ b/docs/user/advanced.rst @@ -321,6 +321,17 @@ Alternatively, you can read the undecoded body from the underlying urllib3 :class:`urllib3.HTTPResponse ` at :attr:`Response.raw `. +.. note:: + + When using ``stream=True``, Requests does not automatically decompress + responses with ``Content-Encoding: gzip`` when accessing + :attr:`Response.raw `. This is intentional. + + If you need decompression while streaming, enable it manually:: + + r = requests.get(url, stream=True) + r.raw.decode_content = True + If you set ``stream`` to ``True`` when making a request, Requests cannot release the connection back to the pool unless you consume all the data or call :meth:`Response.close `. This can lead to