From 03e149d4e17af37547d40518176ccc0d2da7b51e Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Sat, 23 Jan 2016 16:52:30 +0100 Subject: calcurse-caldav: Check response status Bail out if the HTTP status code of any of the replies starts with a digit other than 2. Signed-off-by: Lukas Fleischer --- contrib/caldav/calcurse-caldav.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py index 3c544d6..0feed12 100755 --- a/contrib/caldav/calcurse-caldav.py +++ b/contrib/caldav/calcurse-caldav.py @@ -100,6 +100,11 @@ def remote_query(cmd, path, additional_headers, body): if not resp: return (None, None) + if resp.status - (resp.status % 100) != 200: + die(("The server at %s replied with HTTP status code %d (%s) " + + "while trying to access %s.") % + (hostname, resp.status, resp.reason, path)) + headers = resp.getheaders() body = resp.read().decode('utf-8') -- cgit v1.2.3-70-g09d2