From 8563a5785f6c424bcf86cdd7fe1b293b1cfb5f3a Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 29 Jun 2025 22:19:29 -0500 Subject: [PATCH] tweak --- esphome/components/web_server_base/web_server_base.cpp | 5 +---- esphome/components/web_server_idf/web_server_idf.cpp | 5 ++--- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/esphome/components/web_server_base/web_server_base.cpp b/esphome/components/web_server_base/web_server_base.cpp index 5ae80eedb4..91e9b408bc 100644 --- a/esphome/components/web_server_base/web_server_base.cpp +++ b/esphome/components/web_server_base/web_server_base.cpp @@ -177,10 +177,7 @@ void OTARequestHandler::handleRequest(AsyncWebServerRequest *request) { } #endif // USE_ARDUINO #ifdef USE_ESP_IDF - // For ESP-IDF, we use direct send() instead of beginResponse() - // to ensure the response is sent immediately before the reboot. - // If ota_backend_ is nullptr and we got here, the update completed (either success or failure) - // We'll use ota_success_ flag set by handleUpload to determine the result + // Send response based on the OTA result request->send(200, "text/plain", this->ota_success_ ? "Update Successful!" : "Update Failed!"); return; #endif // USE_ESP_IDF diff --git a/esphome/components/web_server_idf/web_server_idf.cpp b/esphome/components/web_server_idf/web_server_idf.cpp index eac0544512..9478e4748c 100644 --- a/esphome/components/web_server_idf/web_server_idf.cpp +++ b/esphome/components/web_server_idf/web_server_idf.cpp @@ -576,9 +576,6 @@ esp_err_t AsyncWebServer::handle_multipart_upload_(httpd_req_t *r, const char *c return ESP_FAIL; } - // Create reader on heap to reduce stack usage - auto reader = std::make_unique("--" + std::string(boundary_start, boundary_len)); - AsyncWebServerRequest req(r); AsyncWebHandler *handler = nullptr; for (auto *h : this->handlers_) { @@ -597,6 +594,8 @@ esp_err_t AsyncWebServer::handle_multipart_upload_(httpd_req_t *r, const char *c // Upload state std::string filename; size_t index = 0; + // Create reader on heap to reduce stack usage + auto reader = std::make_unique("--" + std::string(boundary_start, boundary_len)); // Configure callbacks reader->set_data_callback([&](const uint8_t *data, size_t len) {