Open asesidaa opened 2 years ago
Hello @aesidaa, thanks for opening this issue.
Just a quick note to either my future self, or anyone taking up implementation:
FileModule
needs a callback or similar mechanism to determine the actual encoding to set, given the served file;I personally can't see this fixed in the immediate future; not in version 3 anyway. Is anyone willing to give it a shot?
Oh and by the way:
unreleased v3.5.0
@geoperez 🙏
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.
With the unreleased v3.5.0, it is now possible to remove the
charset=utf-8
part in thecontent-type
header by settingContentEncoding
tonull
.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 setContentEncoding
tonull
inFileModule
, then add a whitelist (customizable) for those that need it.