diff --git a/fileserver/fileop.go b/fileserver/fileop.go index 7206324..8827e16 100644 --- a/fileserver/fileop.go +++ b/fileserver/fileop.go @@ -86,6 +86,7 @@ func parseContentType(fileName string) string { parts := strings.Split(fileName, ".") if len(parts) >= 2 { suffix := parts[len(parts)-1] + suffix = strings.ToLower(suffix) switch suffix { case "txt": contentType = "text/plain" @@ -109,6 +110,12 @@ func parseContentType(fileName string) string { contentType = "video/mpeg" case "mp4": contentType = "video/mp4" + case "ogv": + contentType = "video/ogg" + case "mov": + contentType = "video/mp4" + case "webm": + contentType = "video/webm" case "jpeg", "JPEG", "jpg", "JPG": contentType = "image/jpeg" case "png", "PNG": @@ -117,6 +124,20 @@ func parseContentType(fileName string) string { contentType = "image/gif" case "svg", "SVG": contentType = "image/svg+xml" + case "heic": + contentType = "image/heic" + case "ico": + contentType = "image/x-icon" + case "bmp": + contentType = "image/bmp" + case "tif", "tiff": + contentType = "image/tiff" + case "psd": + contentType = "image/vnd.adobe.photoshop" + case "webp": + contentType = "image/webp" + case "jfif": + contentType = "image/jpeg" } } diff --git a/server/access-file.c b/server/access-file.c index 1d266e8..def7357 100644 --- a/server/access-file.c +++ b/server/access-file.c @@ -132,6 +132,9 @@ static struct file_type_map ftmap[] = { { "mp3", "audio/mp3" }, { "mpeg", "video/mpeg" }, { "mp4", "video/mp4" }, + { "ogv", "video/ogg" }, + { "mov", "video/mp4" }, + { "webm", "video/webm" }, { "jpg", "image/jpeg" }, { "JPG", "image/jpeg" }, { "jpeg", "image/jpeg" }, @@ -142,6 +145,14 @@ static struct file_type_map ftmap[] = { { "GIF", "image/gif" }, { "svg", "image/svg+xml" }, { "SVG", "image/svg+xml" }, + { "heic", "image/heic" }, + { "ico", "image/x-icon" }, + { "bmp", "image/bmp" }, + { "tif", "image/tiff" }, + { "tiff", "image/tiff" }, + { "psd", "image/vnd.adobe.photoshop" }, + { "webp", "image/webp" }, + { "jfif", "image/jpeg" }, { NULL, NULL }, }; @@ -509,11 +520,16 @@ parse_content_type(const char *filename) return NULL; p++; + char *lower = g_utf8_strdown (p, strlen(p)); + for (i = 0; ftmap[i].suffix != NULL; i++) { - if (strcmp(p, ftmap[i].suffix) == 0) + if (strcmp(lower, ftmap[i].suffix) == 0) { + g_free (lower); return ftmap[i].type; + } } + g_free (lower); return NULL; }