mirror of
https://github.com/rstrouse/ESPSomfy-RTS.git
synced 2026-03-30 08:52:11 +02:00
add gzip support
This commit is contained in:
parent
a64b648f7a
commit
96d66c1b45
3 changed files with 13 additions and 7 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -8,4 +8,5 @@ SomfyController.ino.XIAO_ESP32S3.bin
|
||||||
SomfyController.ino.esp32c3.bin
|
SomfyController.ino.esp32c3.bin
|
||||||
SomfyController.ino.esp32s2.bin
|
SomfyController.ino.esp32s2.bin
|
||||||
.vscode/settings.json
|
.vscode/settings.json
|
||||||
.pio
|
.pio
|
||||||
|
data
|
||||||
|
|
@ -22,6 +22,7 @@ lib_deps =
|
||||||
knolleary/PubSubClient@^2.8
|
knolleary/PubSubClient@^2.8
|
||||||
extra_scripts = pre:minify.py
|
extra_scripts = pre:minify.py
|
||||||
board_build.partitions = min_spiffs.csv
|
board_build.partitions = min_spiffs.csv
|
||||||
|
board_build.filesystem = littlefs
|
||||||
|
|
||||||
[env:esp32devdbg]
|
[env:esp32devdbg]
|
||||||
build_type = debug
|
build_type = debug
|
||||||
|
|
@ -34,4 +35,5 @@ lib_deps =
|
||||||
lsatan/SmartRC-CC1101-Driver-Lib@^2.5.7
|
lsatan/SmartRC-CC1101-Driver-Lib@^2.5.7
|
||||||
knolleary/PubSubClient@^2.8
|
knolleary/PubSubClient@^2.8
|
||||||
extra_scripts = pre:minify.py
|
extra_scripts = pre:minify.py
|
||||||
board_build.partitions = min_spiffs.csv
|
board_build.partitions = min_spiffs.csv
|
||||||
|
board_build.filesystem = littlefs
|
||||||
13
src/Web.cpp
13
src/Web.cpp
|
|
@ -216,14 +216,17 @@ void Web::handleStreamFile(WebServer &server, const char *filename, const char *
|
||||||
webServer.sendCORSHeaders(server);
|
webServer.sendCORSHeaders(server);
|
||||||
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
|
if(server.method() == HTTP_OPTIONS) { server.send(200, "OK"); return; }
|
||||||
esp_task_wdt_reset();
|
esp_task_wdt_reset();
|
||||||
// Load the index html page from the data directory.
|
// Try gzip variant first; streamFile() auto-adds Content-Encoding: gzip for .gz files
|
||||||
Serial.print("Loading file ");
|
String gzFilename = String(filename) + ".gz";
|
||||||
Serial.println(filename);
|
File file = LittleFS.open(gzFilename.c_str(), "r");
|
||||||
File file = LittleFS.open(filename, "r");
|
|
||||||
if (!file) {
|
if (!file) {
|
||||||
Serial.print("Error opening");
|
file = LittleFS.open(filename, "r");
|
||||||
|
}
|
||||||
|
if (!file) {
|
||||||
|
Serial.print("Error opening ");
|
||||||
Serial.println(filename);
|
Serial.println(filename);
|
||||||
server.send(500, _encoding_text, "Error opening file");
|
server.send(500, _encoding_text, "Error opening file");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
esp_task_wdt_delete(NULL);
|
esp_task_wdt_delete(NULL);
|
||||||
server.streamFile(file, encoding);
|
server.streamFile(file, encoding);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue