From 8d28c53fd3e72120fcc8bd13759e67ee4892e91f Mon Sep 17 00:00:00 2001 From: guillempages Date: Thu, 11 Jul 2024 06:08:51 +0200 Subject: [PATCH] [http_request] Fix follow_redirects on arduino (#7054) --- esphome/components/http_request/http_request_arduino.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/esphome/components/http_request/http_request_arduino.cpp b/esphome/components/http_request/http_request_arduino.cpp index 248a85a439..95b1cdc38e 100644 --- a/esphome/components/http_request/http_request_arduino.cpp +++ b/esphome/components/http_request/http_request_arduino.cpp @@ -32,6 +32,13 @@ std::shared_ptr HttpRequestArduino::start(std::string url, std::s watchdog::WatchdogManager wdm(this->get_watchdog_timeout()); + if (this->follow_redirects_) { + container->client_.setFollowRedirects(HTTPC_FORCE_FOLLOW_REDIRECTS); + container->client_.setRedirectLimit(this->redirect_limit_); + } else { + container->client_.setFollowRedirects(HTTPC_DISABLE_FOLLOW_REDIRECTS); + } + #if defined(USE_ESP8266) std::unique_ptr stream_ptr; #ifdef USE_HTTP_REQUEST_ESP8266_HTTPS @@ -59,8 +66,6 @@ std::shared_ptr HttpRequestArduino::start(std::string url, std::s "in your YAML, or use HTTPS"); } #endif // USE_ARDUINO_VERSION_CODE - - container->client_.setFollowRedirects(HTTPC_STRICT_FOLLOW_REDIRECTS); bool status = container->client_.begin(*stream_ptr, url.c_str()); #elif defined(USE_RP2040)