Fix #1294 - add more common mime types

This commit is contained in:
Sergey Lyubka 2021-07-13 19:24:46 +01:00
parent 6b2698a503
commit 5e466f9037
3 changed files with 77 additions and 63 deletions

View File

@ -843,46 +843,53 @@ static const char *guess_content_type(const char *filename) {
} * t, types[] = {
MIME_ENTRY("html", "text/html; charset=utf-8"),
MIME_ENTRY("htm", "text/html; charset=utf-8"),
MIME_ENTRY("shtml", "text/html; charset=utf-8"),
MIME_ENTRY("css", "text/css"),
MIME_ENTRY("js", "text/javascript"),
MIME_ENTRY("mjs", "text/javascript"),
MIME_ENTRY("json", "application/json"),
MIME_ENTRY("ico", "image/x-icon"),
MIME_ENTRY("css", "text/css; charset=utf-8"),
MIME_ENTRY("js", "text/javascript; charset=utf-8"),
MIME_ENTRY("gif", "image/gif"),
MIME_ENTRY("jpg", "image/jpeg"),
MIME_ENTRY("jpeg", "image/jpeg"),
MIME_ENTRY("png", "image/png"),
MIME_ENTRY("svg", "image/svg+xml"),
MIME_ENTRY("txt", "text/plain; charset=utf-8"),
MIME_ENTRY("wav", "audio/wav"),
MIME_ENTRY("mp3", "audio/mpeg"),
MIME_ENTRY("mid", "audio/mid"),
MIME_ENTRY("ogg", "application/ogg"),
MIME_ENTRY("xml", "application/xml"),
MIME_ENTRY("woff", "font/woff"),
MIME_ENTRY("ttf", "font/ttf"),
MIME_ENTRY("json", "application/json"),
MIME_ENTRY("xsl", "application/xml"),
MIME_ENTRY("aac", "audio/aac"),
MIME_ENTRY("avi", "video/x-msvideo"),
MIME_ENTRY("azw", "application/vnd.amazon.ebook"),
MIME_ENTRY("bin", "application/octet-stream"),
MIME_ENTRY("bmp", "image/bmp"),
MIME_ENTRY("bz", "application/x-bzip"),
MIME_ENTRY("bz2", "application/x-bzip2"),
MIME_ENTRY("csv", "text/csv"),
MIME_ENTRY("doc", "application/msword"),
MIME_ENTRY("epub", "application/epub+zip"),
MIME_ENTRY("exe", "application/octet-stream"),
MIME_ENTRY("zip", "application/zip"),
MIME_ENTRY("xls", "application/excel"),
MIME_ENTRY("tgz", "application/tar-gz"),
MIME_ENTRY("tar", "application/tar"),
MIME_ENTRY("gz", "application/gzip"),
MIME_ENTRY("ico", "image/x-icon"),
MIME_ENTRY("json", "application/json"),
MIME_ENTRY("mid", "audio/mid"),
MIME_ENTRY("mjs", "text/javascript"),
MIME_ENTRY("mov", "video/quicktime"),
MIME_ENTRY("mp3", "audio/mpeg"),
MIME_ENTRY("mp4", "video/mp4"),
MIME_ENTRY("mpeg", "video/mpeg"),
MIME_ENTRY("mpg", "video/mpeg"),
MIME_ENTRY("ogg", "application/ogg"),
MIME_ENTRY("pdf", "application/pdf"),
MIME_ENTRY("rar", "application/rar"),
MIME_ENTRY("rtf", "application/rtf"),
MIME_ENTRY("pdf", "application/pdf"),
MIME_ENTRY("mpg", "video/mpeg"),
MIME_ENTRY("webm", "video/webm"),
MIME_ENTRY("mpeg", "video/mpeg"),
MIME_ENTRY("mov", "video/quicktime"),
MIME_ENTRY("mp4", "video/mp4"),
MIME_ENTRY("avi", "video/x-msvideo"),
MIME_ENTRY("csv", "text/csv"),
MIME_ENTRY("bmp", "image/bmp"),
MIME_ENTRY("bin", "application/octet-stream"),
MIME_ENTRY("shtml", "text/html; charset=utf-8"),
MIME_ENTRY("svg", "image/svg+xml"),
MIME_ENTRY("tar", "application/tar"),
MIME_ENTRY("tgz", "application/tar-gz"),
MIME_ENTRY("txt", "text/plain; charset=utf-8"),
MIME_ENTRY("wasm", "application/wasm"),
MIME_ENTRY("wav", "audio/wav"),
MIME_ENTRY("weba", "audio/webm"),
MIME_ENTRY("webm", "video/webm"),
MIME_ENTRY("webp", "image/webp"),
MIME_ENTRY("xls", "application/excel"),
MIME_ENTRY("xml", "application/xml"),
MIME_ENTRY("xsl", "application/xml"),
MIME_ENTRY("zip", "application/zip"),
MIME_ENTRY("3gp", "video/3gpp"),
MIME_ENTRY("7z", "application/x-7z-compressed"),
{NULL, 0, NULL},
};

View File

@ -432,46 +432,53 @@ static const char *guess_content_type(const char *filename) {
} * t, types[] = {
MIME_ENTRY("html", "text/html; charset=utf-8"),
MIME_ENTRY("htm", "text/html; charset=utf-8"),
MIME_ENTRY("shtml", "text/html; charset=utf-8"),
MIME_ENTRY("css", "text/css"),
MIME_ENTRY("js", "text/javascript"),
MIME_ENTRY("mjs", "text/javascript"),
MIME_ENTRY("json", "application/json"),
MIME_ENTRY("ico", "image/x-icon"),
MIME_ENTRY("css", "text/css; charset=utf-8"),
MIME_ENTRY("js", "text/javascript; charset=utf-8"),
MIME_ENTRY("gif", "image/gif"),
MIME_ENTRY("jpg", "image/jpeg"),
MIME_ENTRY("jpeg", "image/jpeg"),
MIME_ENTRY("png", "image/png"),
MIME_ENTRY("svg", "image/svg+xml"),
MIME_ENTRY("txt", "text/plain; charset=utf-8"),
MIME_ENTRY("wav", "audio/wav"),
MIME_ENTRY("mp3", "audio/mpeg"),
MIME_ENTRY("mid", "audio/mid"),
MIME_ENTRY("ogg", "application/ogg"),
MIME_ENTRY("xml", "application/xml"),
MIME_ENTRY("woff", "font/woff"),
MIME_ENTRY("ttf", "font/ttf"),
MIME_ENTRY("json", "application/json"),
MIME_ENTRY("xsl", "application/xml"),
MIME_ENTRY("aac", "audio/aac"),
MIME_ENTRY("avi", "video/x-msvideo"),
MIME_ENTRY("azw", "application/vnd.amazon.ebook"),
MIME_ENTRY("bin", "application/octet-stream"),
MIME_ENTRY("bmp", "image/bmp"),
MIME_ENTRY("bz", "application/x-bzip"),
MIME_ENTRY("bz2", "application/x-bzip2"),
MIME_ENTRY("csv", "text/csv"),
MIME_ENTRY("doc", "application/msword"),
MIME_ENTRY("epub", "application/epub+zip"),
MIME_ENTRY("exe", "application/octet-stream"),
MIME_ENTRY("zip", "application/zip"),
MIME_ENTRY("xls", "application/excel"),
MIME_ENTRY("tgz", "application/tar-gz"),
MIME_ENTRY("tar", "application/tar"),
MIME_ENTRY("gz", "application/gzip"),
MIME_ENTRY("ico", "image/x-icon"),
MIME_ENTRY("json", "application/json"),
MIME_ENTRY("mid", "audio/mid"),
MIME_ENTRY("mjs", "text/javascript"),
MIME_ENTRY("mov", "video/quicktime"),
MIME_ENTRY("mp3", "audio/mpeg"),
MIME_ENTRY("mp4", "video/mp4"),
MIME_ENTRY("mpeg", "video/mpeg"),
MIME_ENTRY("mpg", "video/mpeg"),
MIME_ENTRY("ogg", "application/ogg"),
MIME_ENTRY("pdf", "application/pdf"),
MIME_ENTRY("rar", "application/rar"),
MIME_ENTRY("rtf", "application/rtf"),
MIME_ENTRY("pdf", "application/pdf"),
MIME_ENTRY("mpg", "video/mpeg"),
MIME_ENTRY("webm", "video/webm"),
MIME_ENTRY("mpeg", "video/mpeg"),
MIME_ENTRY("mov", "video/quicktime"),
MIME_ENTRY("mp4", "video/mp4"),
MIME_ENTRY("avi", "video/x-msvideo"),
MIME_ENTRY("csv", "text/csv"),
MIME_ENTRY("bmp", "image/bmp"),
MIME_ENTRY("bin", "application/octet-stream"),
MIME_ENTRY("shtml", "text/html; charset=utf-8"),
MIME_ENTRY("svg", "image/svg+xml"),
MIME_ENTRY("tar", "application/tar"),
MIME_ENTRY("tgz", "application/tar-gz"),
MIME_ENTRY("txt", "text/plain; charset=utf-8"),
MIME_ENTRY("wasm", "application/wasm"),
MIME_ENTRY("wav", "audio/wav"),
MIME_ENTRY("weba", "audio/webm"),
MIME_ENTRY("webm", "video/webm"),
MIME_ENTRY("webp", "image/webp"),
MIME_ENTRY("xls", "application/excel"),
MIME_ENTRY("xml", "application/xml"),
MIME_ENTRY("xsl", "application/xml"),
MIME_ENTRY("zip", "application/zip"),
MIME_ENTRY("3gp", "video/3gpp"),
MIME_ENTRY("7z", "application/x-7z-compressed"),
{NULL, 0, NULL},
};

View File

@ -530,7 +530,7 @@ static void test_http_server(void) {
mg_http_parse(buf, strlen(buf), &hm);
ASSERT(mg_http_get_header(&hm, "Content-Type") != NULL);
ASSERT(mg_strcmp(*mg_http_get_header(&hm, "Content-Type"),
mg_str("text/javascript")) == 0);
mg_str("text/javascript; charset=utf-8")) == 0);
}
{