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)