Closed ziddey closed 3 years ago
Hello, thanks for the PR! Indeed a few small things are wrong the current code:
fallback_to_any
when the associated q=0
I pushed a few commits that fix this. I did not merge your PR since it broke a few tests. Can you please confirm this works for you? I will make a release then.
Closed with 86b47306842496cfbb9d7b76f4e15f6f39485ab8 and 8ae3b3cfb69d76929418e6817ccde45fd292e545
For a ranged request, Chrome sends the accept-encoding header as
identity;q=1, *;q=0
While the
*;q=0
is redundant withidentity;q=1
since identity is always acceptable, it causes flask-compress to fallback to any and improperly compress the response, resulting in ERR_CONTENT_DECODING_FAILED in Chrome.A simple fix would be to simply
if algo=='*' and not quality: continue
or also requirequality
forfallback_to_any
in_choose_compress_algorithm
.https://github.com/colour-science/flask-compress/blob/master/flask_compress.py#L118-L136
A more robust/proper approach would be to add
identity
as an enabled algorithm and then also check forchosen_algorithm == 'identity'
inafter_request
to skip compression.https://github.com/colour-science/flask-compress/blob/master/flask_compress.py#L167-L174