-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not possible to do requests with pre-compressed data #619
Comments
Well, we may assign
Is that satisfies your needs? |
That would work. Though I'm also thinking that providing two ways in the API to instruct aiohttp to compress data makes its use more inconsistent among users: Backwards compatibility may be an issue though, so I'm preparing a pull req with the change you suggested. |
Created pull req: #621 |
Done by #621 |
Currently aiohttp always compresses the request data if the Content-Encoding header is set. If the data is already compressed, aiohttp will compress it a second time. Example:
Looking at client_reqrep, self.update_content_encoding() is called in ClientRequest.init() on line 88. The method first checks if the Content-Encoding header is set, and if it is, self.compress is set to that value and chunking turned on. Otherwise, self.compress (originally set in init() from the constructor's argument with the same name) is used.
Later in send(),
request.add_compression_filter(self.compress)
is called on line 460 if self.compress is set. This leads to the double compression.Suggestion: Only do compression of data in aiohttp if init() is called with the compress argument. If the Content-Encoding header is set, leave it to the user to supply compressed data.
I ran into this user when looking at the raven-python's aiohttp transport (used to send exceptions & al to Sentry at https://github.com/getsentry/raven-aiohttp/blob/c35ca66379f00d58cb8404b51f845f0e754c91b5/raven_aiohttp.py#L41 which gets the data already compressed and Content-Encoding header set.
The text was updated successfully, but these errors were encountered: