mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-31 07:03:55 +00:00 
			
		
		
		
	[http_request]Use std::string for headers (#8225)
This commit is contained in:
		| @@ -18,8 +18,8 @@ namespace esphome { | |||||||
| namespace http_request { | namespace http_request { | ||||||
|  |  | ||||||
| struct Header { | struct Header { | ||||||
|   const char *name; |   std::string name; | ||||||
|   const char *value; |   std::string value; | ||||||
| }; | }; | ||||||
|  |  | ||||||
| // Some common HTTP status codes | // 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_); |     container->client_.setUserAgent(this->useragent_); | ||||||
|   } |   } | ||||||
|   for (const auto &header : headers) { |   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 |   // 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); |   container->set_secure(secure); | ||||||
|  |  | ||||||
|   for (const auto &header : headers) { |   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(); |   const int body_len = body.length(); | ||||||
|   | |||||||
| @@ -124,7 +124,7 @@ void OnlineImage::update() { | |||||||
|     default: |     default: | ||||||
|       accept_mime_type = "image/*"; |       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); |   headers.push_back(accept_header); | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user