From b5b4047241702d6e0e329248b7454cae57a1d945 Mon Sep 17 00:00:00 2001 From: Jesse Hills <3060199+jesserockz@users.noreply.github.com> Date: Fri, 21 Jun 2024 15:42:37 +1200 Subject: [PATCH] Use err from getting chunk length --- esphome/components/http_request/http_request_idf.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/esphome/components/http_request/http_request_idf.cpp b/esphome/components/http_request/http_request_idf.cpp index 1c38e988fe..a5fa3ddfa5 100644 --- a/esphome/components/http_request/http_request_idf.cpp +++ b/esphome/components/http_request/http_request_idf.cpp @@ -117,6 +117,12 @@ std::shared_ptr HttpRequestIDF::start(std::string url, std::strin ESP_LOGV(TAG, "HTTP Response is chunked"); int length = 0; err = esp_http_client_get_chunk_length(client, &length); + if (err != ESP_OK) { + this->status_momentary_error("failed", 1000); + ESP_LOGE(TAG, "Failed to get chunk length: %s", esp_err_to_name(err)); + esp_http_client_cleanup(client); + return nullptr; + } container->content_length = length; } const auto status_code = esp_http_client_get_status_code(client);