Fix web UI hang: use send_P for 15 KB HTML response
The setContentLength + send(200,type,"") + sendContent() three-step pattern was unreliable — WebServer::send() with an empty String body can mark the response complete internally, causing sendContent() to be silently dropped. send_P() handles Content-Length, header prep, and chunked body delivery from const flash data in a single call with zero heap allocation. Made-with: Cursor
This commit is contained in:
12
src/main.cpp
12
src/main.cpp
@@ -2240,17 +2240,7 @@ window.addEventListener('resize',capDrawWave);
|
||||
)HTML";
|
||||
|
||||
static void handleRoot() {
|
||||
// ETag based on compile timestamp — browser caches until next flash
|
||||
server.sendHeader("ETag", "\"" __DATE__ __TIME__ "\"");
|
||||
server.sendHeader("Cache-Control", "no-cache"); // revalidate via ETag, don't re-download
|
||||
if (server.hasHeader("If-None-Match") &&
|
||||
server.header("If-None-Match") == "\"" __DATE__ __TIME__ "\"") {
|
||||
server.send(304); // Not Modified — browser uses cached copy, saves ~15 KB
|
||||
return;
|
||||
}
|
||||
server.setContentLength(sizeof(kHtml) - 1);
|
||||
server.send(200, "text/html; charset=utf-8", "");
|
||||
server.sendContent(kHtml, sizeof(kHtml) - 1);
|
||||
server.send_P(200, "text/html; charset=utf-8", kHtml, sizeof(kHtml) - 1);
|
||||
}
|
||||
|
||||
static void handleLog() {
|
||||
|
||||
Reference in New Issue
Block a user