File tree Expand file tree Collapse file tree
storage/gcloud/aio/storage Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -671,6 +671,16 @@ async def _download_stream(
671671 headers = headers or {}
672672 headers .update (await self ._headers ())
673673
674+ # aiohttp and requests automatically decompress the body if this
675+ # argument is not passed, unless a user has explicitly disabled that
676+ # option at the session level in the case of aiohttp. We follow the
677+ # user setting by default (by passing None) and only explicitly disable
678+ # it when we know that the object is not compressed (when the
679+ # Accept-Encoding header is missing).
680+ auto_decompress = None
681+ if 'accept-encoding' not in {k .lower () for k in headers }:
682+ auto_decompress = False
683+
674684 s = AioSession (session ) if session else self .session
675685
676686 if BUILD_GCLOUD_REST :
@@ -685,7 +695,7 @@ async def _download_stream(
685695 return StreamResponse (
686696 await s .get (
687697 url , headers = headers , params = params or {},
688- timeout = timeout ,
698+ timeout = timeout , auto_decompress = auto_decompress ,
689699 ),
690700 )
691701
You can’t perform that action at this time.
0 commit comments