Stream portal templates via TemplateEngineAsyncWeb chunked wrapper

Use the DFTE async integration helper so portal HTML chunk callbacks handle
zero-length buffers and no-progress retries without terminating transfers
early on constrained hosts.
This commit is contained in:
2026-05-06 00:44:56 +10:00
parent 396a6e07db
commit 95e9f9a751
+11 -3
View File
@@ -12,6 +12,7 @@
#include "templates/RootShell.h"
#include "templates/PortalAppJS.h"
#include <TemplateEngine.h>
#include <TemplateEngineAsyncWeb.h>
#include <cstring>
#if defined(ESP8266) || defined(ESP32)
@@ -95,9 +96,16 @@ AsyncWebServerResponse* beginTemplateResponse(AsyncWebServerRequest* request,
const char* templateData) {
bundle->context.setRegistry(&bundle->registry);
TemplateRenderer::initializeContext(bundle->context, templateData);
return request->beginChunkedResponse(String(FPSTR(HTTP_HEAD_CT)),
[bundle](uint8_t *buffer, size_t maxLen, size_t /*index*/) -> size_t {
return TemplateRenderer::renderNextChunk(bundle->context, buffer, maxLen);
return TemplateEngineAsyncWeb::beginSafeChunkedResponse(
request,
String(FPSTR(HTTP_HEAD_CT)),
bundle,
[](BundleT& responseBundle, uint8_t *buffer, size_t maxLen, size_t /*index*/) -> size_t {
return TemplateEngineAsyncWeb::renderTemplateChunkWithRetries(
responseBundle.context, buffer, maxLen, 128);
},
[](const BundleT& responseBundle) -> bool {
return TemplateEngineAsyncWeb::isTemplateTerminal(responseBundle.context);
}
);
}