diff --git a/esphome/components/http_request/http_request_idf.cpp b/esphome/components/http_request/http_request_idf.cpp index 138e0438f4..d6fac7a133 100644 --- a/esphome/components/http_request/http_request_idf.cpp +++ b/esphome/components/http_request/http_request_idf.cpp @@ -90,7 +90,7 @@ std::shared_ptr HttpRequestIDF::start(std::string url, std::strin int write_left = body_len; int write_index = 0; const char *buf = body.c_str(); - while (body_len > 0) { + while (write_left > 0) { int written = esp_http_client_write(client, buf + write_index, write_left); if (written < 0) { err = ESP_FAIL;