Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

Commit

Permalink
🐛 Returning {} for non-json content-type responses
Browse files Browse the repository at this point in the history
  • Loading branch information
Sigmanificient committed Aug 31, 2021
1 parent e00bedc commit 426d135
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pincer/core/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async def __send(

raise RuntimeError("Unsupported RequestMethod has been passed.")

log.debug(f"new {method.value.name} {route} | {dumps(data)}")
log.debug(f"new {method.value} {route} | {dumps(data)}")

async with sender(
f"{self.endpoint}/{route}",
Expand All @@ -147,7 +147,11 @@ async def __send(
"Returning json response."
)

return await res.json()
return (
await res.json()
if res.content_type == "application/json"
else {}
)

exception = self.__http_exceptions.get(res.status)

Expand Down

0 comments on commit 426d135

Please sign in to comment.