Skip to content

Commit

Permalink
fix: make sure to set content-type for file type (#3837)
Browse files Browse the repository at this point in the history
This PR fixes a hidden bug that has been here since some time, where the response headers content-type was not set.

This will failed if the user is using the client, as the fake_req actually will try to get the content-type from the headers.
  • Loading branch information
aarnphm authored May 8, 2023
1 parent 7fca40e commit 4e1b471
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/bentoml/_internal/io_descriptors/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,14 @@ async def to_http_response(self, obj: FileType, ctx: Context | None = None):
)
set_cookies(res, ctx.response.cookies)
else:
res = Response(body)
res = Response(
body,
headers={
"content-type": self._mime_type
if self._mime_type
else "application/octet-stream"
},
)
return res

async def to_proto(self, obj: FileType) -> pb.File:
Expand Down

0 comments on commit 4e1b471

Please sign in to comment.