I write small http server. I need to set Content-Type when I send file in response. How it should be done? Should Content-Type field be preset in some map for each file or it might be set basing on file extension? If yes, how about *.ico
files that are PNG
actually?
So what's the common practice?
So what's the common practice?
Common practice, for static files, is to infer the Content-Type from the file extension.
If yes, how about *.ico files that are PNG actually?
Then common practice would give the wrong content-type.
You could override it on a case-by-case basis from a configuration file.
eg Apache HTTPD would allow:
<Files "favicon.ico">
ForceType image/png
</Files>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.