How to send very large html pages?
Hi,
currently i´m using beginResponseStream to send my webpages to webserver. Its works fine. But if the webpage is over a certain size, the ESP32 (Wroom) crashes.
My code look like this:
void Func(AsyncWebServerRequest *request) {
AsyncResponseStream *response = request->beginResponseStream("text/html");
response->addHeader("Server","ESP Async Web Server");
[...]
response->println("");
response->println(" IP-Adresse: ");
response->printf (" %s \n", WiFi.localIP().toString().c_str());
response->println(" ");
[...]
request->send(response);
}
To solve this RAM overflow problem I tried to understand the "beginChunkedResponse" example https://github.com/me-no-dev/ESPAsyncWebServer#chunked-response But i dont know, how i can apply this example on my code. The webpage is too big so i cannot push it into a string variable which the example needs.
Any suggestions?
Before, i used the standard Sync ESP8266Webserver. Its allowed me to send chunks by demand
void Func::handleRoot() {
String html;
server->sendHeader("Cache-Control", "no-cache, no-store, must-revalidate");
server->sendHeader("Pragma", "no-cache");
server->sendHeader("Expires", "-1");
server->setContentLength(CONTENT_LENGTH_UNKNOWN);
server->send(200, "text/html", "");
[...]
html.concat("\n");
html.concat("IP-Adresse: \n");
sprintf(buffer, "%s \n", WiFi.localIP().toString().c_str());
html.concat(buffer);
html.concat(" \n");
server->sendContent(html.c_str()); html = "";
html.concat("\n");
[...]
server->send(200, "text/html", html.c_str()); // Send HTTP status 200 (Ok) and send some text to the browser/client
}
By using server->sendContent(html.c_str()); i´m able to send the buffer out and fill it again,
@me-no-dev -> Its possible to add the feature in your AsyncWebserver too?