Skip to content
Myr

_detected_encoding

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

authored by Kenneth Reitz · committed by Kenneth Reitz · parent 9451ae2 · Browse files · 1 file+12 added−8 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+12 added−8 removed

  • other:+12 added−8 removed

1 file+12 added−8 removed

modified:requests/models.py+12 added-8 removed
705 unmodified lines
706 gen = stream_decode_response_unicode(gen, self)707708 return gen709710 def iter_lines(self, chunk_size=10 * 1024, decode_unicode=True):710 def iter_lines(self, chunk_size=10 * 1024, decode_unicode=None):711 """Iterates over the response data, one line at a time. This712 avoids reading the content at once into memory for large713 responses.714 """
40 unmodified lines
755756 self._content_consumed = True757 return self._content758759 def _detected_encoding(self):760 try:761 detected = chardet.detect(self.content) or {}762 return detected.get('encoding')763764 # Trust that chardet isn't available or something went terribly wrong.765 except Exception:766 pass767768769 @property770 def text(self):771 """Content of the response, in unicode.772
6 unmodified lines
779 encoding = self.encoding780781 # Fallback to auto-detected encoding if chardet is available.782 if self.encoding is None:773 try:774 detected = chardet.detect(self.content) or {}775 encoding = detected.get('encoding')783 encoding = self._detected_encoding()784777 # Trust that chardet isn't available or something went terribly wrong.778 except Exception:779 pass780785 # Decode unicode from given encoding.786 try:787 content = str(self.content, encoding, errors='replace')788 except (UnicodeError, TypeError):
18 unmodified lines