mirror of
https://github.com/alexhopeoconnor/WiFiManager.git
synced 2026-10-04 02:48:13 +10:00
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:
@@ -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);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user