Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 80af245

Browse files
JosePineiromathieucarbou
andauthoredJul 18, 2025··
Add Content-Type for MP4 files (#234)
* Add Content-Type for MP4 files This patch ensures that HTTP responses serving .mp4 files include the correct Content-Type: video/mp4 header. This improves media compatibility across browsers and clients, and adheres to standard MIME type conventions for MP4 files. No changes were made outside of content-type handling for MP4. If the correct content type is not sent, many browsers will ignore the Content-Disposition: inline header and download the file instead of playing it in-browser. In such cases, the browser assumes it cannot render the content inline and defaults to download behavior. This fix ensures MP4 files are properly recognized and played directly in the browser when expected. * Add files via upload * Update literals.h --------- Co-authored-by: Mathieu Carbou <mathieu.carbou@gmail.com>
1 parent 0a48baf commit 80af245

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed
 

‎src/WebResponses.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,6 +680,8 @@ void AsyncFileResponse::_setContentTypeFromPath(const String &path) {
680680
_contentType = T_text_xml;
681681
} else if (strcmp(dot, T__pdf) == 0) {
682682
_contentType = T_application_pdf;
683+
} else if (strcmp(dot, T__mp4) == 0) {
684+
_contentType = T_video_mp4;
683685
} else if (strcmp(dot, T__zip) == 0) {
684686
_contentType = T_application_zip;
685687
} else if (strcmp(dot, T__gz) == 0) {

‎src/literals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ static constexpr const char *T__ico = ".ico";
114114
static constexpr const char *T__jpg = ".jpg";
115115
static constexpr const char *T__js = ".js";
116116
static constexpr const char *T__json = ".json";
117+
static constexpr const char *T__mp4 = ".mp4";
117118
static constexpr const char *T__pdf = ".pdf";
118119
static constexpr const char *T__png = ".png";
119120
static constexpr const char *T__svg = ".svg";
@@ -145,6 +146,7 @@ static constexpr const char *T_text_css = "text/css";
145146
static constexpr const char *T_text_event_stream = "text/event-stream";
146147
static constexpr const char *T_text_html = "text/html";
147148
static constexpr const char *T_text_plain = "text/plain";
149+
static constexpr const char *T_video_mp4 = "video/mp4";
148150
static constexpr const char *T_text_xml = "text/xml";
149151

150152
// Response codes

0 commit comments

Comments
 (0)
Please sign in to comment.