not all HTTP responses have content-type

This commit is contained in:
jesopo 2019-08-02 17:33:16 +01:00
parent 0b39ed6410
commit d093027431

View file

@ -90,7 +90,7 @@ def request(url: str, method: str="GET", get_params: dict={},
signal.signal(signal.SIGALRM, signal.SIG_IGN)
response_headers = utils.CaseInsensitiveDict(dict(response.headers))
content_type = response.headers["Content-Type"].split(";", 1)[0]
content_type = response.headers.get("Content-Type", "").split(";", 1)[0]
def _decode_data():
return response_content.decode(response.encoding or fallback_encoding)