def content(self) -> Union[bytes, bytearray, None]:
'''
Retrieves the content in the original form.
Private codes should NOT use this as it incurs duplicate
encoding/decoding.
'''
if self._content is None:
raise ValueError('content is not set.')
if self.content_type == 'application/octet-stream':
return self._content
elif self.content_type == 'application/json':
return json.loads(self._content.decode('utf-8'),
object_pairs_hook=OrderedDict)
elif self.content_type == 'text/plain':
return self._content.decode('utf-8')
elif self.content_type == 'multipart/form-data':
return self._content
else:
raise RuntimeError('should not reach here') # pragma: no cover
评论列表
文章目录