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

Incorrect encoding detected when no encoding is given #2042

Closed
untitaker opened this issue May 13, 2014 · 6 comments
Closed

Incorrect encoding detected when no encoding is given #2042

untitaker opened this issue May 13, 2014 · 6 comments

Comments

@untitaker
Copy link
Contributor

On https://mozorg.cdn.mozilla.net/media/caldata/FrenchHolidays.ics, the encoding is set to ISO-8859-1, although no encoding was given in the headers, which is why i think it should be None instead.

@Lukasa
Copy link
Member

Lukasa commented May 13, 2014

This is well-known behaviour in requests, and comes right out of RFC-2616. We go into it here in the documentation, but in short: RFC 2616 says that if a Content-Type is received that is of type text/* (any text content type) but no charset is present, we must assume ISO-8859-1.

@untitaker
Copy link
Contributor Author

Is there a way to detect this fallback as a user of requests?

@Lukasa
Copy link
Member

Lukasa commented May 13, 2014

Sure:

fallback_to_latin1 = (not 'charset' in r.headers['Content-Type']) and (r.headers['Content-Type'].startswith('text/')

@untitaker
Copy link
Contributor Author

Okay, thanks!

@untitaker
Copy link
Contributor Author

With http://evertpot.com/http-11-updated/, could there be any change on this?

@Lukasa
Copy link
Member

Lukasa commented Jun 12, 2014

@untitaker Way ahead of you, see #2086. =)

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants