mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
anti-rollback!
This commit is contained in:
@@ -155,25 +155,23 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) {
|
|||||||
// 400 (invalid)
|
// 400 (invalid)
|
||||||
int ret_codes[7] = {400, 200, 404, 400, 401, 400, 404};
|
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->setCode(ret_codes[return_code]);
|
response->setLength();
|
||||||
// response->setLength();
|
response->setContentType("application/json; charset=utf-8");
|
||||||
// response->setContentType("application/json; charset=utf-8");
|
request->send(response);
|
||||||
// request->send(response);
|
|
||||||
|
|
||||||
// serialize JSON to string to ensure correct content-length and avoid HTTP parsing errors (issue #2752)
|
// serialize JSON to string to ensure correct content-length and avoid HTTP parsing errors (issue #2752)
|
||||||
std::string output_str;
|
// std::string output_str;
|
||||||
serializeJson(output, output_str);
|
// serializeJson(output, output_str);
|
||||||
request->send(ret_codes[return_code], "application/json; charset=utf-8", output_str.c_str());
|
// request->send(ret_codes[return_code], "application/json; charset=utf-8", output_str.c_str());
|
||||||
|
|
||||||
#if defined(EMSESP_UNITY)
|
#if defined(EMSESP_UNITY)
|
||||||
// store the result so we can test with Unity later
|
// store the result so we can test with Unity later
|
||||||
storeResponse(output);
|
storeResponse(output);
|
||||||
#endif
|
#endif
|
||||||
#if defined(EMSESP_STANDALONE) && !defined(EMSESP_UNITY)
|
#if defined(EMSESP_STANDALONE) && !defined(EMSESP_UNITY)
|
||||||
// add back when AsyncWebServer 3.9.3+ is released
|
std::string output_str;
|
||||||
// std::string output_str;
|
serializeJson(output, output_str);
|
||||||
// serializeJson(output, output_str);
|
|
||||||
Serial.printf("%sweb output: %s[%s] %s(%d)%s %s%s",
|
Serial.printf("%sweb output: %s[%s] %s(%d)%s %s%s",
|
||||||
COLOR_WHITE,
|
COLOR_WHITE,
|
||||||
COLOR_BRIGHT_CYAN,
|
COLOR_BRIGHT_CYAN,
|
||||||
@@ -186,8 +184,6 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) {
|
|||||||
Serial.println();
|
Serial.println();
|
||||||
EMSESP::logger().debug("web output: %s %s", request->url().c_str(), output_str.c_str());
|
EMSESP::logger().debug("web output: %s %s", request->url().c_str(), output_str.c_str());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
delete response; // TODO remove when AsyncWebServer 3.9.3+ is released
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(EMSESP_UNITY)
|
#if defined(EMSESP_UNITY)
|
||||||
|
|||||||
Reference in New Issue
Block a user