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:
parent
b667ceaced
commit
8b7aa4c110
@ -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
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user