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

Exclude User Agents from compression #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ircama
Copy link

@Ircama Ircama commented Jul 27, 2022

Some User Agent should be excluded from compression to avoid decoding issues.

For instance, Safari 11.1.2 included in Mac OS X 10.11.6 gives this status message: Safari can't open the page. The error is: “cannot decode raw data” (NSURLErrorDomain:-1015). Its UA is: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15"

This browser can be excluded from compression by setting app.config["COMPRESS_EXCLUDE_UA"] = ['Mac OS X 10'].

Also, app.config["COMPRESS_TRACE"] = True enables to log the User Agent.

@alexprengere
Copy link
Collaborator

If a specific browser is unable to decode a certain type of compression, shouldn't it just say so in the Accept-Encoding HTTP header?

@Ircama
Copy link
Author

Ircama commented Jul 29, 2022

This is the request header:

Accept-Encoding: gzip, deflate
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/11.1.2 Safari/605.1.15

With either gzip or deflate, the browser shows:

Safari can't open the page.
"cannot decode raw data" (NSURLErrorDomain:-1015).

I have not found any relevant note on how to fix this.

I do not know whether this helps: https://stackoverflow.com/questions/32169082/safari-cannot-decode-raw-data-when-using-gzip

The only quick solution was to exclude the user agent.

@alexprengere
Copy link
Collaborator

I am not sure the issue relates to the page you linked, as in the relevant part of the code, it does not look like we are including any filename in the compressed content (that would be GzipFile first argument).

  • It is issue happening regardless of the Python version used in the server?
  • Does this happen for deflate as well?
  • Is only a specific version of Safari affected?

I do not have access to Safari so I cannot do much investigation.

@Ircama
Copy link
Author

Ircama commented Jul 30, 2022

I am not sure the issue relates to the page you linked, as in the relevant part of the code, it does not look like we are including any filename in the compressed content (that would be GzipFile first argument).

Yes, right.

It is issue happening regardless of the Python version used in the server?

Regardless the Python version: I am using Python 3.10.4 and Python 3.7.10 on Ubuntu 22.04 LTS. Both have the issue.

Does this happen for deflate as well?

Yes

Is only a specific version of Safari affected?

Yes, I believe it is related to Safari 11.1.2 included in OS X El Capitan 10.11.6 (old MacBook Air 2009 hw).

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

Successfully merging this pull request may close these issues.

2 participants