diff --git a/src/WebResponses.cpp b/src/WebResponses.cpp index c1dbe4b8e..2878a2c1d 100644 --- a/src/WebResponses.cpp +++ b/src/WebResponses.cpp @@ -631,7 +631,7 @@ void AsyncFileResponse::_setContentTypeFromPath(const String &path) { const char *dot = strrchr(cpath, '.'); if (!dot) { - _contentType = T_text_plain; + _contentType = T_application_octet_stream; return; } @@ -663,20 +663,20 @@ void AsyncFileResponse::_setContentTypeFromPath(const String &path) { _contentType = T_font_woff; } else if (strcmp(dot, T__ttf) == 0) { _contentType = T_font_ttf; - } else if (strcmp(dot, T__eot) == 0) { - _contentType = T_font_eot; } else if (strcmp(dot, T__xml) == 0) { _contentType = T_text_xml; } else if (strcmp(dot, T__pdf) == 0) { _contentType = T_application_pdf; } else if (strcmp(dot, T__mp4) == 0) { _contentType = T_video_mp4; - } else if (strcmp(dot, T__zip) == 0) { - _contentType = T_application_zip; - } else if (strcmp(dot, T__gz) == 0) { - _contentType = T_application_x_gzip; - } else { + } else if (strcmp(dot, T__opus) == 0) { + _contentType = T_audio_opus; + } else if (strcmp(dot, T__webm) == 0) { + _contentType = T_video_webm; + } else if (strcmp(dot, T__txt) == 0) { _contentType = T_text_plain; + } else { + _contentType = T_application_octet_stream; } #endif } diff --git a/src/literals.h b/src/literals.h index ed2a29a50..fc0fff13c 100644 --- a/src/literals.h +++ b/src/literals.h @@ -103,35 +103,36 @@ static constexpr const char *T_RCT_EVENT = "RCT_EVENT"; static constexpr const char *T_ERROR = "ERROR"; // extensions & MIME-Types -static constexpr const char *T__avif = ".avif"; -static constexpr const char *T__css = ".css"; -static constexpr const char *T__eot = ".eot"; -static constexpr const char *T__gif = ".gif"; -static constexpr const char *T__gz = ".gz"; -static constexpr const char *T__htm = ".htm"; -static constexpr const char *T__html = ".html"; -static constexpr const char *T__ico = ".ico"; -static constexpr const char *T__jpg = ".jpg"; -static constexpr const char *T__js = ".js"; -static constexpr const char *T__json = ".json"; -static constexpr const char *T__mp4 = ".mp4"; -static constexpr const char *T__pdf = ".pdf"; -static constexpr const char *T__png = ".png"; -static constexpr const char *T__svg = ".svg"; -static constexpr const char *T__ttf = ".ttf"; -static constexpr const char *T__webp = ".webp"; -static constexpr const char *T__woff = ".woff"; -static constexpr const char *T__woff2 = ".woff2"; -static constexpr const char *T__xml = ".xml"; -static constexpr const char *T__zip = ".zip"; -static constexpr const char *T_application_javascript = "application/javascript"; +static constexpr const char *T__avif = ".avif"; // AVIF: Highly compressed images. Compatible with all modern browsers. +static constexpr const char *T__csv = ".csv"; // CSV: Data logging and configuration +static constexpr const char *T__css = ".css"; // CSS: Styling for web interfaces +static constexpr const char *T__gif = ".gif"; // GIF: Simple animations. Legacy support +static constexpr const char *T__gz = ".gz"; // GZ: compressed files +static constexpr const char *T__htm = ".htm"; // HTM: Web interface files +static constexpr const char *T__html = ".html"; // HTML: Web interface files +static constexpr const char *T__ico = ".ico"; // ICO: Favicons, system icons. Legacy support +static constexpr const char *T__jpg = ".jpg"; // JPEG/JPG: Photos. Legacy support +static constexpr const char *T__js = ".js"; // JavaScript: Interactive functionality +static constexpr const char *T__json = ".json"; // JSON: Data exchange format +static constexpr const char *T__mp4 = ".mp4"; // MP4: Proprietary format. Worse compression than WEBM. +static constexpr const char *T__opus = ".opus"; // OPUS: High compression audio format +static constexpr const char *T__pdf = ".pdf"; // PDF: Universal document format +static constexpr const char *T__png = ".png"; // PNG: Icons, logos, transparency. Legacy support +static constexpr const char *T__svg = ".svg"; // SVG: Vector graphics, icons (scalable, tiny file sizes) +static constexpr const char *T__ttf = ".ttf"; // TTF: Font file. Legacy support +static constexpr const char *T__txt = ".txt"; // TXT: Plain text files +static constexpr const char *T__webm = ".webm"; // WebM: Video. Open source, optimized for web. Compatible with all modern browsers. +static constexpr const char *T__webp = ".webp"; // WebP: Highly compressed images. Compatible with all modern browsers. +static constexpr const char *T__woff = ".woff"; // WOFF: Font file. Legacy support +static constexpr const char *T__woff2 = ".woff2"; // WOFF2: Better compression. Compatible with all modern browsers. +static constexpr const char *T__xml = ".xml"; // XML: Configuration and data files +static constexpr const char *T_application_javascript = "application/javascript"; // Obsolete type for JavaScript static constexpr const char *T_application_json = "application/json"; static constexpr const char *T_application_msgpack = "application/msgpack"; +static constexpr const char *T_application_octet_stream = "application/octet-stream"; static constexpr const char *T_application_pdf = "application/pdf"; -static constexpr const char *T_application_x_gzip = "application/x-gzip"; static constexpr const char *T_app_xform_urlencoded = "application/x-www-form-urlencoded"; -static constexpr const char *T_application_zip = "application/zip"; -static constexpr const char *T_font_eot = "font/eot"; +static constexpr const char *T_audio_opus = "audio/opus"; static constexpr const char *T_font_ttf = "font/ttf"; static constexpr const char *T_font_woff = "font/woff"; static constexpr const char *T_font_woff2 = "font/woff2"; @@ -143,11 +144,14 @@ static constexpr const char *T_image_svg_xml = "image/svg+xml"; static constexpr const char *T_image_webp = "image/webp"; static constexpr const char *T_image_x_icon = "image/x-icon"; static constexpr const char *T_text_css = "text/css"; +static constexpr const char *T_text_csv = "text/csv"; static constexpr const char *T_text_event_stream = "text/event-stream"; static constexpr const char *T_text_html = "text/html"; +static constexpr const char *T_text_javascript = "text/javascript"; static constexpr const char *T_text_plain = "text/plain"; -static constexpr const char *T_video_mp4 = "video/mp4"; static constexpr const char *T_text_xml = "text/xml"; +static constexpr const char *T_video_mp4 = "video/mp4"; +static constexpr const char *T_video_webm = "video/webm"; // Response codes static constexpr const char *T_HTTP_CODE_100 = "Continue";