diff options
author | Ian Stapleton Cordasco <graffatcolmingov@gmail.com> | 2020-11-29 12:19:15 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-29 12:19:15 -0600 |
commit | 589c4547338b592b1fb77c65663d8aa6fbb7e38b (patch) | |
tree | ab2bf3a78ef33375f1fd3c4db5ef6210b1e53b2c | |
parent | d0359c9460eb83759734dd898b1dd633f5477b89 (diff) | |
parent | 5855dd711f0ab9c9c4782574b8814b1e4c7f98cc (diff) | |
download | python-requests-589c4547338b592b1fb77c65663d8aa6fbb7e38b.tar.gz |
Merge pull request #5673 from jjmaldonis/master
updated `get_encoding_from_headers` to return utf-8 if the content type is set to application/json
-rw-r--r-- | requests/utils.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/requests/utils.py b/requests/utils.py index 16d57762..db67938e 100644 --- a/requests/utils.py +++ b/requests/utils.py @@ -503,6 +503,10 @@ def get_encoding_from_headers(headers): if 'text' in content_type: return 'ISO-8859-1' + if 'application/json' in content_type: + # Assume UTF-8 based on RFC 4627: https://www.ietf.org/rfc/rfc4627.txt since the charset was unset + return 'utf-8' + def stream_decode_response_unicode(iterator, r): """Stream decodes a iterator.""" |