def _response_to_json(resp: Response) -> bytes:
"""Generate a json byte string from a response received through requests."""
# we store only the top of the file because core dumps can become very large
# also: we do not want to store more potentially sensitive data than necessary
# to determine whether there is a leak or not
return json.dumps({
'text': resp.content[0:50*1024].decode(errors='replace'),
'status_code': resp.status_code,
'headers': dict(resp.headers),
'url': resp.url,
}).encode()
评论列表
文章目录