fix web server OOM
This commit is contained in:
parent
2b2bc95cf2
commit
fedc14bcb4
@ -221,7 +221,10 @@ void CrossPointWebServer::handleClient() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void CrossPointWebServer::handleRoot() const {
|
void CrossPointWebServer::handleRoot() const {
|
||||||
server->send(200, "text/html", HomePageHtml);
|
// Use chunked sending for consistency with handleFileList (avoids String allocation)
|
||||||
|
server->setContentLength(strlen(HomePageHtml));
|
||||||
|
server->send(200, "text/html", "");
|
||||||
|
server->sendContent_P(HomePageHtml);
|
||||||
Serial.printf("[%lu] [WEB] Served root page\n", millis());
|
Serial.printf("[%lu] [WEB] Served root page\n", millis());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,7 +322,14 @@ bool CrossPointWebServer::isEpubFile(const String& filename) const {
|
|||||||
return lower.endsWith(".epub");
|
return lower.endsWith(".epub");
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrossPointWebServer::handleFileList() const { server->send(200, "text/html", FilesPageHtml); }
|
void CrossPointWebServer::handleFileList() const {
|
||||||
|
// Use chunked sending to avoid allocating 64KB+ contiguous RAM for String conversion.
|
||||||
|
// The original server->send(200, "text/html", FilesPageHtml) fails when heap is fragmented
|
||||||
|
// because it tries to create a String from the large PROGMEM array.
|
||||||
|
server->setContentLength(strlen(FilesPageHtml));
|
||||||
|
server->send(200, "text/html", "");
|
||||||
|
server->sendContent_P(FilesPageHtml);
|
||||||
|
}
|
||||||
|
|
||||||
void CrossPointWebServer::handleFileListData() const {
|
void CrossPointWebServer::handleFileListData() const {
|
||||||
// Get current path from query string (default to root)
|
// Get current path from query string (default to root)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user