ESPHome 2025.5.0
Loading...
Searching...
No Matches
http_request_idf.h
Go to the documentation of this file.
1#pragma once
2
3#include "http_request.h"
4
5#ifdef USE_ESP_IDF
6
7#include <esp_event.h>
8#include <esp_http_client.h>
9#include <esp_netif.h>
10#include <esp_tls.h>
11
12namespace esphome {
13namespace http_request {
14
16 public:
17 HttpContainerIDF(esp_http_client_handle_t client) : client_(client) {}
18 int read(uint8_t *buf, size_t max_len) override;
19 void end() override;
20
22 void feed_wdt();
23
24 void set_response_headers(std::map<std::string, std::list<std::string>> &response_headers) {
25 this->response_headers_ = std::move(response_headers);
26 }
27
28 protected:
29 esp_http_client_handle_t client_;
30};
31
33 public:
34 void dump_config() override;
35
36 void set_buffer_size_rx(uint16_t buffer_size_rx) { this->buffer_size_rx_ = buffer_size_rx; }
37 void set_buffer_size_tx(uint16_t buffer_size_tx) { this->buffer_size_tx_ = buffer_size_tx; }
38
39 protected:
40 std::shared_ptr<HttpContainer> perform(std::string url, std::string method, std::string body,
41 std::list<Header> request_headers,
42 std::set<std::string> collect_headers) override;
43 // if zero ESP-IDF will use DEFAULT_HTTP_BUF_SIZE
44 uint16_t buffer_size_rx_{};
45 uint16_t buffer_size_tx_{};
46
48 static esp_err_t http_event_handler(esp_http_client_event_t *evt);
49};
50
51} // namespace http_request
52} // namespace esphome
53
54#endif // USE_ESP_IDF
std::map< std::string, std::list< std::string > > response_headers_
int read(uint8_t *buf, size_t max_len) override
HttpContainerIDF(esp_http_client_handle_t client)
void set_response_headers(std::map< std::string, std::list< std::string > > &response_headers)
void feed_wdt()
Feeds the watchdog timer if the executing task has one attached.
void set_buffer_size_tx(uint16_t buffer_size_tx)
void set_buffer_size_rx(uint16_t buffer_size_rx)
std::shared_ptr< HttpContainer > perform(std::string url, std::string method, std::string body, std::list< Header > request_headers, std::set< std::string > collect_headers) override
static esp_err_t http_event_handler(esp_http_client_event_t *evt)
Monitors the http client events to gather response headers.
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7