Default the encoding of "text" media subtypes to "ISO-8859-1"
authorJohannes Gorset <jgorset@gmail.com>
Sat, 21 Jan 2012 10:01:45 +0000 (11:01 +0100)
committerJohannes Gorset <jgorset@gmail.com>
Sat, 21 Jan 2012 10:01:45 +0000 (11:01 +0100)
Ref. RFC2616 (HyperText Transfer Protocol), section 3.7.1 (Canonicalization and Text Defaults).

requests/utils.py

index c7ab0a4..95dea4b 100644 (file)
@@ -276,6 +276,9 @@ def get_encoding_from_headers(headers):
     if 'charset' in params:
         return params['charset'].strip("'\"")
 
+    if 'text' in content_type:
+        return 'ISO-8859-1'
+
 
 def unicode_from_html(content):
     """Attempts to decode an HTML string into unicode.