Skip to content
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

Content-Encoding with multiple encodings not supported #1441

Closed
jbramleycl opened this issue Sep 17, 2018 · 1 comment
Closed

Content-Encoding with multiple encodings not supported #1441

jbramleycl opened this issue Sep 17, 2018 · 1 comment

Comments

@jbramleycl
Copy link
Contributor

@jbramleycl jbramleycl commented Sep 17, 2018

It is possible for a server to respond with a Content-Encoding header like:
Content-Encoding: deflate, deflate

From RFC7231:

If one or more encodings have been applied to a representation, the
sender that applied the encodings MUST generate a Content-Encoding
header field that lists the content codings in the order in which
they were applied.

This can be tested with:

def test_multiple_content_encodings():
    data = zlib.compress(zlib.compress(b'foo'))
    fp = BytesIO(data)
    r = HTTPResponse(fp, headers={'Content-Encoding': 'deflate, deflate'})
    assert r.data == b'foo'

Would it make sense to do something like:

if len(self.headers.get('content-encoding').split(',') > 1:
    self._decoder = MultiDecoder(self.headers.get('content-encoding'))

where MultiDecoder just iterates through the list applying standard decoders?

@sethmlarson
Copy link
Member

@sethmlarson sethmlarson commented Sep 17, 2018

TIL that Content-Encoding allows for nested encodings. Do you have an example site that does this? We haven't hit this problem until now.

I'm open to a PR that implements this behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.