Skip to content

Commit

Permalink
fix handling bytes
Browse files Browse the repository at this point in the history
Changes:

- fix handling bytes in JSON mode

FIXME: why is JSON mode the default
  • Loading branch information
devkral committed Dec 17, 2024
1 parent 9d3f976 commit b3a6b8e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/en/docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ hide:

# Release Notes


## 3.6.1

### Fixed

- Fix returning plain bytes when media_type is MediaType.JSON.

## 3.6.0

### Added
Expand Down
2 changes: 2 additions & 0 deletions esmerald/responses/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,8 @@ def make_response(self, content: Any) -> Union[bytes, str]:
):
return b""
if self.media_type == MediaType.JSON:
if isinstance(content, (bytes, memoryview)):
return content
return cast(
bytes,
json_encoder(
Expand Down

0 comments on commit b3a6b8e

Please sign in to comment.