0
0
Fork 0
mirror of https://github.com/matrix-construct/construct synced 2025-02-18 09:40:12 +01:00

modules/root: Supplement content-type/MIME-type with ircd::fs::magic interface.

This commit is contained in:
Jason Volk 2018-02-17 21:27:13 -08:00
parent f5197cc8ff
commit 092b4d3ace

View file

@ -49,6 +49,7 @@ get_root(client &client, const resource::request &request)
rsplit(filename, '.').second
};
char content_type_buf[64];
string_view content_type; switch(hash(extension))
{
case hash("css"): content_type = "text/css; charset=utf-8"; break;
@ -70,13 +71,7 @@ get_root(client &client, const resource::request &request)
case hash("txt"): content_type = "text/plain; charset=utf-8"; break;
default:
{
if(!empty(extension))
log::warning
{
"Unknown mime type for extension '%s'", extension
};
content_type = "application/octet-stream";
content_type = fs::magic::mime(content_type_buf, string_view{content});
break;
}
}