def apparent_encoding(self):
"""The apparent encoding, provided by the chardet library."""
def _encoding(content):
return chardet.detect(content)['encoding']
@gen.coroutine
def _stream_apparent_encoding():
content = yield self.content
raise Return(_encoding(content))
if not isinstance(self.raw, HTTPMessageDelegate):
raise TypeError('self.raw must be a trip.adapters.MessageDelegate')
if self.raw.stream:
return _stream_apparent_encoding()
else:
return _encoding(self.content)
评论列表
文章目录