Skip to content

Commit

Permalink
updated mime types
Browse files Browse the repository at this point in the history
  • Loading branch information
doudar committed Dec 16, 2024
1 parent d0cd20a commit 6ebe6f4
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions src/http/HTTPRoutes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,21 @@ void HTTPRoutes::_handleLittleFSFile() {

if (LittleFS.exists(filename)) {
File file = LittleFS.open(filename, FILE_READ);
if (fileType == "gz") {
fileType = "html";
String mimeType;
if (fileType == "js") {
mimeType = "application/javascript";
} else if (fileType == "css") {
mimeType = "text/css";
} else if (fileType == "html" || fileType == "gz") {
mimeType = "text/html";
} else {
mimeType = "text/" + fileType;
}
currentServer->streamFile(file, "text/" + fileType);

// Add caching headers
currentServer->sendHeader("Cache-Control", "public, max-age=31536000");
currentServer->sendHeader("Expires", "Thu, 31 Dec 2037 23:59:59 GMT");
currentServer->streamFile(file, mimeType);
file.close();
SS2K_LOG(HTTP_SERVER_LOG_TAG, "Served %s", filename.c_str());
} else if (!LittleFS.exists("/index.html")) {
Expand Down

0 comments on commit 6ebe6f4

Please sign in to comment.