Avoid blank page (NULL) as response

This commit is contained in:
MichaelDvP
2022-12-10 16:09:47 +01:00
parent bba70ce852
commit 7e888f6408
3 changed files with 24 additions and 2 deletions

View File

@@ -101,8 +101,15 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) {
}
// output json buffer
auto * response = new PrettyAsyncJsonResponse(false, EMSESP_JSON_SIZE_XXLARGE_DYN);
JsonObject output = response->getRoot();
auto * response = new PrettyAsyncJsonResponse(false, EMSESP_JSON_SIZE_XXLARGE_DYN);
if (!response->getSize()) {
response = new PrettyAsyncJsonResponse(false, 256);
response->setCode(507);
response->setLength();
request->send(response); // Insufficient Storage
return;
}
JsonObject output = response->getRoot();
// call command
uint8_t return_code = Command::process(request->url().c_str(), is_admin, input, output);