Don't decode empty response from DELETE
On success, DELETE returns no data. Attempting to parse it into JSON causes
a crash. Check for content before parsing.
diff --git a/client.py b/client.py
index f3d7f3a..77ed0b9 100644
--- a/client.py
+++ b/client.py
@@ -138,7 +138,7 @@
task_id: An integer id for the task.
Returns:
- A JSON encoded response.
+ A JSON encoded response, if there is content in the response.
Raises:
HTTPError: a 4XX client error or 5XX server error response was returned.
@@ -148,4 +148,7 @@
self._Url('tasks/%d' % task_id),
headers=self.headers))
r.raise_for_status()
- return r.json()
+ # DELETE returns nothing on success, don't try and parse it.
+ if len(r.content) > 0:
+ return r.json()
+ return