1
0
mirror of https://github.com/esphome/esphome.git synced 2025-02-14 17:08:22 +00:00

[http_request]Use std::string for headers (#8225)

This commit is contained in:
guillempages 2025-02-11 01:39:03 +01:00 committed by GitHub
parent b667ceaced
commit 8b7aa4c110
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 5 additions and 5 deletions

View File

@ -18,8 +18,8 @@ namespace esphome {
namespace http_request {
struct Header {
const char *name;
const char *value;
std::string name;
std::string value;
};
// Some common HTTP status codes

View File

@ -96,7 +96,7 @@ std::shared_ptr<HttpContainer> HttpRequestArduino::start(std::string url, std::s
container->client_.setUserAgent(this->useragent_);
}
for (const auto &header : headers) {
container->client_.addHeader(header.name, header.value, false, true);
container->client_.addHeader(header.name.c_str(), header.value.c_str(), false, true);
}
// returned needed headers must be collected before the requests

View File

@ -84,7 +84,7 @@ std::shared_ptr<HttpContainer> HttpRequestIDF::start(std::string url, std::strin
container->set_secure(secure);
for (const auto &header : headers) {
esp_http_client_set_header(client, header.name, header.value);
esp_http_client_set_header(client, header.name.c_str(), header.value.c_str());
}
const int body_len = body.length();

View File

@ -124,7 +124,7 @@ void OnlineImage::update() {
default:
accept_mime_type = "image/*";
}
accept_header.value = (accept_mime_type + ",*/*;q=0.8").c_str();
accept_header.value = accept_mime_type + ",*/*;q=0.8";
headers.push_back(accept_header);