When serving static files using Ktor, how do you o...
# ktor
When serving static files using Ktor, how do you override what content type Ktor sets on the response?
Looks like you have to reimplement
(more specifically
doesn’t do anything) yourself, and it’s not super easy, not super clean.
@ribesg Could you please log a feature request with your use-cases at https://youtrack.jetbrains.com/newIssue?project=KTOR ?
I’m mostly trying to work around a different problem, which is that Ktor assigns a wrong content type to
files (like
in my case, or
) and while clients retrieving these files usually don’t care about content type, I wanted to set it as json so that I could see them directly in browser
I understand that Ktor should respect the “official” list of mime types so I don’t expect that to change, these kind of files having no default/expected content type anyway. But the inability to somehow override the content type kinda surprised me. I tried an interceptor, but you are not allowed to set the value of the Content-Type header which is weird
Then that’s a different issue. Could you please log the specific problem with the wrong assignment, or tell me what you’d expect these file types to have?
As I said there is no specific content type associated to these files, my Google skills only got me to
or eventually
which is useful for specific debugging but may not make sense. I don’t think the mime types list should be changed but I don’t know what should be done to let users do what they want in this case. I’ll open a general issue