Skip to content
Myr

Only decode unicode from http headers

Before adoption: this commit came in with the history the project adopted, so no landing records it.

HTTP client, not HTML #115

authored by Kenneth Reitz · committed by Kenneth Reitz · parent ce3b85a · Browse files · 1 file+0 added−13 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+0 added−13 removed

  • other:+0 added−13 removed

1 file+0 added−13 removed

modified:requests/utils.py-13 removed
130 unmodified lines
131 encoding = get_encoding_from_headers(r.headers)132133 if encoding:134 try:135 print '!'135 return unicode(r.content, encoding)136 except UnicodeError:137 tried_encodings.append(encoding)138140 # Try every encodings from <meta ... charset=XXX>141 encodings = get_encodings_from_content(r.content)142143 for encoding in encodings:144 if encoding in tried_encodings:145 continue146 try:147148 return unicode(r.content, encoding)149 except (UnicodeError, TypeError):150 tried_encodings.append(encoding)151139 # Fall back:140 try:141 return unicode(r.content, encoding, errors='replace')142 except TypeError:
10 unmodified lines