diff --git a/esphome/components/http_request/http_request.h b/esphome/components/http_request/http_request.h index 3046c8a749..5402155393 100644 --- a/esphome/components/http_request/http_request.h +++ b/esphome/components/http_request/http_request.h @@ -90,16 +90,6 @@ inline bool should_collect_header(const std::vector &collect_header return false; } -/// Lowercase a range of strings into a vector -template inline std::vector lowercase_headers(Iter begin, Iter end) { - std::vector result; - result.reserve(std::distance(begin, end)); - for (auto it = begin; it != end; ++it) { - result.push_back(str_lower_case(*it)); - } - return result; -} - /* * HTTP Container Read Semantics * ============================= @@ -374,15 +364,19 @@ class HttpRequestComponent : public Component { std::shared_ptr start(const std::string &url, const std::string &method, const std::string &body, const std::list
&request_headers, const std::set &collect_headers) { - return this->perform(url, method, body, request_headers, - lowercase_headers(collect_headers.begin(), collect_headers.end())); + return this->start(url, method, body, request_headers, + std::vector(collect_headers.begin(), collect_headers.end())); } std::shared_ptr start(const std::string &url, const std::string &method, const std::string &body, const std::list
&request_headers, const std::vector &collect_headers) { - return this->perform(url, method, body, request_headers, - lowercase_headers(collect_headers.begin(), collect_headers.end())); + std::vector lower; + lower.reserve(collect_headers.size()); + for (const auto &h : collect_headers) { + lower.push_back(str_lower_case(h)); + } + return this->perform(url, method, body, request_headers, lower); } protected: