mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
Avoid 507, reduce buffer stepwise until it fits
This commit is contained in:
@@ -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<JsonObject>()) {
|
||||
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"]) {
|
||||
|
||||
Reference in New Issue
Block a user