From 40fc0fd2f97fc38573c66669314a1d14450c3c26 Mon Sep 17 00:00:00 2001 From: proddy Date: Sun, 30 Nov 2025 15:39:13 +0100 Subject: [PATCH] anti-rollback! --- src/web/WebAPIService.cpp | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index e7c21c90d..12647383e 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -155,25 +155,23 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) { // 400 (invalid) int ret_codes[7] = {400, 200, 404, 400, 401, 400, 404}; - // TODO add back when AsyncWebServer 3.9.3+ is released - // response->setCode(ret_codes[return_code]); - // response->setLength(); - // response->setContentType("application/json; charset=utf-8"); - // request->send(response); + response->setCode(ret_codes[return_code]); + response->setLength(); + response->setContentType("application/json; charset=utf-8"); + request->send(response); // serialize JSON to string to ensure correct content-length and avoid HTTP parsing errors (issue #2752) - std::string output_str; - serializeJson(output, output_str); - request->send(ret_codes[return_code], "application/json; charset=utf-8", output_str.c_str()); + // std::string output_str; + // serializeJson(output, output_str); + // request->send(ret_codes[return_code], "application/json; charset=utf-8", output_str.c_str()); #if defined(EMSESP_UNITY) // store the result so we can test with Unity later storeResponse(output); #endif #if defined(EMSESP_STANDALONE) && !defined(EMSESP_UNITY) - // add back when AsyncWebServer 3.9.3+ is released - // std::string output_str; - // serializeJson(output, output_str); + std::string output_str; + serializeJson(output, output_str); Serial.printf("%sweb output: %s[%s] %s(%d)%s %s%s", COLOR_WHITE, COLOR_BRIGHT_CYAN, @@ -186,8 +184,6 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) { Serial.println(); EMSESP::logger().debug("web output: %s %s", request->url().c_str(), output_str.c_str()); #endif - - delete response; // TODO remove when AsyncWebServer 3.9.3+ is released } #if defined(EMSESP_UNITY)