diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index 5fe1a40d2..1fc33e827 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -101,14 +101,12 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) { } // output json buffer - auto * response = new PrettyAsyncJsonResponse(false, EMSESP_JSON_SIZE_XXLARGE_DYN); - if (!response->getSize()) { + size_t buffer = EMSESP_JSON_SIZE_XXLARGE_DYN; + auto * response = new PrettyAsyncJsonResponse(false, buffer); + while (!response->getSize()) { delete response; - response = new PrettyAsyncJsonResponse(false, 256); - response->setCode(507); // Insufficient Storage - response->setLength(); - request->send(response); - return; + buffer -= 1024; + response = new PrettyAsyncJsonResponse(false, buffer); } JsonObject output = response->getRoot(); diff --git a/src/web/WebCustomizationService.cpp b/src/web/WebCustomizationService.cpp index 5b2289d64..16c267585 100644 --- a/src/web/WebCustomizationService.cpp +++ b/src/web/WebCustomizationService.cpp @@ -200,14 +200,12 @@ void WebCustomizationService::devices(AsyncWebServerRequest * request) { // send back list of device entities void WebCustomizationService::device_entities(AsyncWebServerRequest * request, JsonVariant & json) { if (json.is()) { - auto * response = new MsgpackAsyncJsonResponse(true, EMSESP_JSON_SIZE_XXXLARGE_DYN); - if (!response->getSize()) { + size_t buffer = EMSESP_JSON_SIZE_XXXLARGE_DYN; + auto * response = new PrettyAsyncJsonResponse(true, buffer); + while (!response->getSize()) { delete response; - response = new MsgpackAsyncJsonResponse(true, 256); - response->setCode(507); // Insufficient Storage - response->setLength(); - request->send(response); - return; + buffer -= 1024; + response = new PrettyAsyncJsonResponse(true, buffer); } for (const auto & emsdevice : EMSESP::emsdevices) { if (emsdevice->unique_id() == json["id"]) { diff --git a/src/web/WebDataService.cpp b/src/web/WebDataService.cpp index e5187f69e..26ad1fa36 100644 --- a/src/web/WebDataService.cpp +++ b/src/web/WebDataService.cpp @@ -165,14 +165,12 @@ void WebDataService::sensor_data(AsyncWebServerRequest * request) { // Compresses the JSON using MsgPack https://msgpack.org/index.html void WebDataService::device_data(AsyncWebServerRequest * request, JsonVariant & json) { if (json.is()) { - auto * response = new MsgpackAsyncJsonResponse(false, EMSESP_JSON_SIZE_XXXLARGE_DYN); - if (!response->getSize()) { + size_t buffer = EMSESP_JSON_SIZE_XXXLARGE_DYN; + auto * response = new PrettyAsyncJsonResponse(false, buffer); + while (!response->getSize()) { delete response; - response = new MsgpackAsyncJsonResponse(false, 256); - response->setCode(507); // Insufficient Storage - response->setLength(); - request->send(response); - return; + buffer -= 1024; + response = new PrettyAsyncJsonResponse(false, buffer); } for (const auto & emsdevice : EMSESP::emsdevices) { if (emsdevice->unique_id() == json["id"]) {