diff --git a/src/esphttpdutils.cpp b/src/esphttpdutils.cpp index 3fa1c84..f59b3de 100644 --- a/src/esphttpdutils.cpp +++ b/src/esphttpdutils.cpp @@ -83,6 +83,14 @@ const char *errorToStatus(httpd_err_code_t error) } } +esp_err_t webserver_prepare_response(httpd_req_t *req) +{ + CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Connection", "close") + CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "*") + + return ESP_OK; +} + esp_err_t webserver_resp_send_succ(httpd_req_t *req, const char *type, std::string_view body) { CALL_AND_EXIT_ON_ERROR(httpd_resp_set_type, req, type) diff --git a/src/esphttpdutils.h b/src/esphttpdutils.h index 435356c..77c8cf6 100644 --- a/src/esphttpdutils.h +++ b/src/esphttpdutils.h @@ -21,6 +21,8 @@ tl::expected urlverify(std::string_view str); const char *errorToStatus(httpd_err_code_t error); +esp_err_t webserver_prepare_response(httpd_req_t *req); + esp_err_t webserver_resp_send_succ(httpd_req_t *req, const char *type, std::string_view body); esp_err_t webserver_resp_send_err(httpd_req_t *req, httpd_err_code_t error, const char *type, std::string_view body);