Skip to content

Commit

Permalink
trying again, that didn't make snese
Browse files Browse the repository at this point in the history
  • Loading branch information
notque committed Jul 31, 2024
1 parent bb8df42 commit ed27520
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions auditmiddleware/_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,16 @@ def _create_events(self, target_project, res_id,
events = []

# Check if the response has a JSON body
has_json_body = (response and
(response.content_length or 0) > 0 and
response.content_type == "application/json")
if has_json_body:
try:
# Only attempt to access response.text if we think it's JSON
has_json_body = bool(response.text)
except UnicodeDecodeError:
# If we can't decode the text, it's not JSON
has_json_body = False
has_json_body = False
if response and (response.content_length or 0) > 0:
if response.content_type == "application/json":
try:
# Attempt to access response.text
response.text
has_json_body = True
except UnicodeDecodeError:
# If we can't decode the text, it's not JSON
has_json_body = False

# check for update operations (POST, PUT, PATCH)
if request.method[0] == 'P' and has_json_body:
Expand Down

0 comments on commit ed27520

Please sign in to comment.