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

Cannot control charset in ContentType header #567

Open
asesidaa opened this issue Jul 13, 2022 · 3 comments
Open

Cannot control charset in ContentType header #567

asesidaa opened this issue Jul 13, 2022 · 3 comments
Labels
area:core Issue with EmbedIO core (server, modules, etc.) area:files Issue with FileModule and/or file providers breaking Requires one or more breaking changes. enhancement pinned Pinned issues are not closed automatically when stale. v3.x

Comments

@asesidaa
Copy link

With the unreleased v3.5.0, it is now possible to remove the charset=utf-8 part in the content-type header by setting ContentEncoding to null.

However, when using FileModule to serve static files, there doesn't seem to be a way to set this.

Actually, I believe for mime types that are not for text, charset is not needed at all. Therefore, I would propose set ContentEncoding to null in FileModule, then add a whitelist (customizable) for those that need it.

@rdeago rdeago added bug enhancement breaking Requires one or more breaking changes. v3.x area:files Issue with FileModule and/or file providers area:core Issue with EmbedIO core (server, modules, etc.) pinned Pinned issues are not closed automatically when stale. labels Jul 13, 2022
@rdeago rdeago changed the title Cannot control charset in content type header in FileModule Cannot control charset in ContentType header Jul 13, 2022
@rdeago
Copy link
Collaborator

rdeago commented Jul 13, 2022

Hello @aesidaa, thanks for opening this issue.

Just a quick note to either my future self, or anyone taking up implementation:

  • MIME type providers need to be able to specify whether a MIME type needs an encoding;
  • FileModule needs a callback or similar mechanism to determine the actual encoding to set, given the served file;
  • for immutable file providers at the least, the association between path and encoding should be cached.

I personally can't see this fixed in the immediate future; not in version 3 anyway. Is anyone willing to give it a shot?

@rdeago rdeago removed the bug label Jul 13, 2022
@rdeago
Copy link
Collaborator

rdeago commented Jul 13, 2022

Oh and by the way:

unreleased v3.5.0

@geoperez 🙏

@asesidaa
Copy link
Author

Hello @aesidaa, thanks for opening this issue.

Just a quick note to either my future self, or anyone taking up implementation:

  • MIME type providers need to be able to specify whether a MIME type needs an encoding;
  • FileModule needs a callback or similar mechanism to determine the actual encoding to set, given the served file;
  • for immutable file providers at the least, the association between path and encoding should be cached.

I personally can't see this fixed in the immediate future; not in version 3 anyway. Is anyone willing to give it a shot?

I currently write a quick workaround according to https://stackoverflow.com/questions/70643383/which-mime-types-contain-charset-utf-8-directive, only add charset=utf-8 for text/* and common ones like application/json, since this is really only needed for content that are consumed as text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:core Issue with EmbedIO core (server, modules, etc.) area:files Issue with FileModule and/or file providers breaking Requires one or more breaking changes. enhancement pinned Pinned issues are not closed automatically when stale. v3.x
Projects
None yet
Development

No branches or pull requests

2 participants