summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Stapleton Cordasco <graffatcolmingov@gmail.com>2020-11-29 12:19:15 -0600
committerGitHub <noreply@github.com>2020-11-29 12:19:15 -0600
commit589c4547338b592b1fb77c65663d8aa6fbb7e38b (patch)
treeab2bf3a78ef33375f1fd3c4db5ef6210b1e53b2c
parentd0359c9460eb83759734dd898b1dd633f5477b89 (diff)
parent5855dd711f0ab9c9c4782574b8814b1e4c7f98cc (diff)
downloadpython-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.py4
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."""