Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: UTF-8 chars "outside" ASCII will set content-type to application/octet-stream #1520

Open
DanielBachmann opened this issue Sep 20, 2024 · 2 comments
Labels
bug Something isn't working as expected waiting for response Waiting for follow up

Comments

@DanielBachmann
Copy link

Description

When returning a Response with a body that contains a non-ASCII character, like "ö, ä, ü, etc." in german or a 😊 for that matter, the responses content-type will be set to application/octet-stream.
That in turn will result in "save file" dialog if the route was called in a browser.

Steps To Reproduce

  1. create new dart frog project
  2. add a utf-8 character that isn't in ASCII as well to the Response body in index.dart
  3. run dev server
  4. call in Browser

Expected Behavior

Getting a text/plain response (with utf-8 encoding) when using utf-8 character in a Response body String.

Additional Context

My apologies if this is expected behavior.
This basically doesn't matter that much if one would use dart frog for an API or just set the header manually, but it took me quite some time to figure out what is wrong when doing the tutorials.

@DanielBachmann DanielBachmann added the bug Something isn't working as expected label Sep 20, 2024
@tomarra
Copy link
Contributor

tomarra commented Sep 24, 2024

Hi @DanielBachmann 👋 Thanks for opening up this issue.

Would you be able to upload a minimal reproductive project with this setup so we can take a look at it locally? From the details that you described here the team believes that this is expected behavior. We think this is actually being driven by the default behavior of shelf in that if it sees something in the response body that doesn't fit with utf-8 encoding then it will default back to the application/octet-stream response type.

@tomarra tomarra moved this from Needs Triage to Community in VGV Open Source 🦄 🧙🌟 Sep 24, 2024
@tomarra tomarra added the waiting for response Waiting for follow up label Sep 24, 2024
@DanielBachmann
Copy link
Author

Hi @tomarra

Sure, I created a new project, added the route /with_umlaut by adding /routes/with_umlaut.dart and zipped it before the first start with dart_frog dev.

It shows the described behavior on the /with_umlaut route.
Attached of course :-)
utf8_test.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected waiting for response Waiting for follow up
Projects
Status: Community
Development

No branches or pull requests

2 participants