Skip to content

Commit

Permalink
Handle status_code 204 responses for non-DELETE methods (#45)
Browse files Browse the repository at this point in the history
* Handle status_code 204 responses for non-DELETE methods

Stopping an agent is a PUT request that returns a 204.

* be defensive: return OK if a response content-type header is None
  • Loading branch information
justnoise authored May 19, 2020
1 parent d4d167b commit bd31d11
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion pybuildkite/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def request(
if with_pagination:
response = self._get_paginated_response(response)
return response
if method == "DELETE":
if (method == "DELETE" or response.status_code == 204 or
response.headers.get('content-type') is None):
return response.ok
if headers.get("Accept") is None or headers.get("Accept") == "application/json":
return response.json()
Expand Down

0 comments on commit bd31d11

Please sign in to comment.