Skip to content

Commit

Permalink
Fix checking response success (#72)
Browse files Browse the repository at this point in the history
Referencing response.text consumes the response body, so only do it here if the response is an error.

* Bump version
  • Loading branch information
ahaith authored Dec 6, 2021
1 parent 2e14537 commit eb9e32b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from setuptools import setup

# Update version here when you want to increment the version in PyPi
sdk_version = '0.4.3'
sdk_version = '0.4.4'

# If no ZEGAMI_SDK_VERSION set use the version
try:
Expand Down
12 changes: 6 additions & 6 deletions zegami_sdk/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@ def _check_status(response, is_async_request=False):
If allow is set to True, doesn't throw an exception.
"""
code = response.status if is_async_request else response.status_code
response_message = 'Bad request response ({}): {}\n\nbody:\n{}'.format(
code, response.reason, response.text
)

assert response.ok, response_message
if not response.ok:
code = response.status if is_async_request else response.status_code
response_message = 'Bad request response ({}): {}\n\nbody:\n{}'.format(
code, response.reason, response.text
)
raise AssertionError(response_message)


def _auth_get(self, url, return_response=False, **kwargs):
Expand Down

0 comments on commit eb9e32b

Please sign in to comment.