Пример #1
0
 def _headers_encoding(self):
     content_type = self.headers.get('Content-Type')
     if content_type:
         m = self._ENCODING_RE.search(content_type)
         if m:
             encoding = m.group(1)
             if encoding_exists(encoding):
                 return encoding
Пример #2
0
 def _get_encoding(self, infer=False):
     enc = self._declared_encoding()
     if enc and not encoding_exists(enc):
         enc = None
     if not enc and infer:
         enc = self._body_inferred_encoding()
     if not enc:
         enc = self._DEFAULT_ENCODING
     return resolve_encoding(enc)