From 7e7d21722adb1d456b269f387b909e86ff6828e2 Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <lfleischer@calcurse.org>
Date: Sun, 24 Jan 2016 13:44:27 +0100
Subject: calcurse-caldav: Show debug output before checking status

Make sure we print the headers and the body of a HTTP response in debug
mode, even if the HTTP status code indicates failure.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
---
 contrib/caldav/calcurse-caldav.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

(limited to 'contrib')

diff --git a/contrib/caldav/calcurse-caldav.py b/contrib/caldav/calcurse-caldav.py
index 262f4ee..ff6bdc1 100755
--- a/contrib/caldav/calcurse-caldav.py
+++ b/contrib/caldav/calcurse-caldav.py
@@ -102,11 +102,6 @@ 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')
 
@@ -116,6 +111,11 @@ def remote_query(cmd, path, additional_headers, body):
             print("< " + line)
         print()
 
+    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))
+
     return (headers, body)
 
 def get_hrefmap(conn, uid=None):
-- 
cgit v1.2.3-70-g09d2