aiogoogle icon indicating copy to clipboard operation
aiogoogle copied to clipboard

Aiohttp auto decompression can not be easily disabled

Open Downchuck opened this issue 11 months ago • 2 comments

The auto_decompress=True default of aiohttp can't be disabled via session_factory = lambda: AiohttpSession(auto_decompress=False) as that gets in the way of other HTTP requests in the session which rely on a hard-coded Accept-Encoding: gzip; the request object does not take in kwargs in aiogoogle, so it can't pass auto_decompress=False into the individual aiohttp request parameters either.

This flag is used with Google storage when skipping gzip decompression on download_file.

Downchuck avatar Mar 19 '25 06:03 Downchuck

This is not the right way to do it, but shows the behavior I am using for this one very particular use case. It may make sense to simply add an optional request.kwargs object

aiogoogle/sessions/aiohttp_session.py

                kwargs = {"auto_decompress": False} if request.media_download else {}
                return await self.request(
                    method=request.method,
                    url=request.url,
                    headers=request.headers,
                    data=request.data,
                    json=request.json,
                    timeout=request.timeout,
                    ssl=request._verify_ssl,
                    proxy=HTTP_PROXY,
                    **kwargs
                )

Downchuck avatar Mar 19 '25 06:03 Downchuck

Hi @Downchuck

I like your solution. I'll approve and release a new version if you can submit a PR with the proposed change. Thanks!

omarryhan avatar Mar 19 '25 13:03 omarryhan