def get_body_str(res: HTTPResponse) -> str: try: for h in res.getheaders(): if h[0] == "Content-Type": if "charset=" in h[1].split(';')[1]: encoding: str = h[1].split(';')[1].split("=")[1] except: encoding: str = "utf-8" result: str = '' for line in res.readlines(): result += (line.decode(encoding)) return result
def _print_error(response: HTTPResponse) -> None: _logger.warning("Response status: " + str(response.status) + "\n" + "Reason: " + response.reason + "\n" + "Messsage:\n" + str(b"\n".join(response.readlines())))