Skip to content

Commit d99576f

Browse files
Fix Content-Disposition header causing files to download instead of play inline
Co-authored-by: mathieucarbou <61346+mathieucarbou@users.noreply.github.com>
1 parent d98d92c commit d99576f

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/WebResponses.cpp

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -747,10 +747,9 @@ AsyncFileResponse::AsyncFileResponse(FS &fs, const String &path, const char *con
747747
char *filename = (char *)path.c_str() + filenameStart;
748748
snprintf(buf, sizeof(buf), T_attachment, filename);
749749
addHeader(T_Content_Disposition, buf, false);
750-
} else {
751-
// Serve file inline (display in browser)
752-
addHeader(T_Content_Disposition, T_inline, false);
753750
}
751+
// For inline display, don't set Content-Disposition header
752+
// Browser will display inline by default when download=false
754753

755754
_code = 200;
756755
}
@@ -782,10 +781,10 @@ AsyncFileResponse::AsyncFileResponse(File content, const String &path, const cha
782781

783782
if (download) {
784783
snprintf_P(buf, sizeof(buf), PSTR("attachment; filename=\"%s\""), filename);
785-
} else {
786-
snprintf_P(buf, sizeof(buf), PSTR("inline"));
784+
addHeader(T_Content_Disposition, buf, false);
787785
}
788-
addHeader(T_Content_Disposition, buf, false);
786+
// For inline display, don't set Content-Disposition header
787+
// Browser will display inline by default when download=false
789788
}
790789

791790
size_t AsyncFileResponse::_fillBuffer(uint8_t *data, size_t len) {

0 commit comments

Comments
 (0)