From f72bdb7c45ddd601b1e7e88ef77d8437beb382bc Mon Sep 17 00:00:00 2001 From: rstephan Date: Sun, 20 Nov 2022 17:40:55 +0100 Subject: [PATCH] Use none chunked transfer for "/json" endpoint (#1379) --- .../jomjol_tfliteclass/server_tflite.cpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/code/components/jomjol_tfliteclass/server_tflite.cpp b/code/components/jomjol_tfliteclass/server_tflite.cpp index aa2b67a3..a9a782e7 100644 --- a/code/components/jomjol_tfliteclass/server_tflite.cpp +++ b/code/components/jomjol_tfliteclass/server_tflite.cpp @@ -201,20 +201,18 @@ esp_err_t handler_json(httpd_req_t *req) ESP_LOGD(TAG, "handler_JSON uri: %s", req->uri); - char _query[100]; -// char _size[10]; - httpd_resp_set_hdr(req, "Access-Control-Allow-Origin", "*"); httpd_resp_set_type(req, "application/json"); std::string zw = tfliteflow.getJSON(); if (zw.length() > 0) - httpd_resp_sendstr_chunk(req, zw.c_str()); - - string query = std::string(_query); - - /* Respond with an empty chunk to signal HTTP response completion */ - httpd_resp_sendstr_chunk(req, NULL); + { + httpd_resp_send(req, zw.c_str(), zw.length()); + } + else + { + httpd_resp_send(req, NULL, 0); + } #ifdef DEBUG_DETAIL_ON LogFile.WriteHeapInfo("handler_JSON - Done");