From 3e81c4f3b6a3219fba7e986acf059300df8f3225 Mon Sep 17 00:00:00 2001 From: rembo10 Date: Fri, 3 Jul 2015 21:01:46 -0700 Subject: [PATCH] Fix for #2183. Check to make sure the response has headers before trying to parse them --- headphones/request.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/headphones/request.py b/headphones/request.py index a8b9e84d..6c8afda1 100644 --- a/headphones/request.py +++ b/headphones/request.py @@ -206,7 +206,7 @@ def server_message(response): message = None # First attempt is to 'read' the response as HTML - if "text/html" in response.headers.get("content-type"): + if response.headers and "text/html" in response.headers.get("content-type"): try: soup = BeautifulSoup(response.content, "html5lib") except Exception: