ESPHome
2026.3.0-dev
Loading...
Searching...
No Matches
esphome
components
http_request
http_request.cpp
Go to the documentation of this file.
1
#include "
http_request.h
"
2
3
#include "
esphome/core/log.h
"
4
5
#include <cinttypes>
6
7
namespace
esphome::http_request
{
8
9
static
const
char
*
const
TAG =
"http_request"
;
10
11
void
HttpRequestComponent::dump_config
() {
12
ESP_LOGCONFIG(TAG,
13
"HTTP Request:\n"
14
" Timeout: %ums\n"
15
" User-Agent: %s\n"
16
" Follow redirects: %s\n"
17
" Redirect limit: %d"
,
18
this->
timeout_
, this->
useragent_
, YESNO(this->
follow_redirects_
), this->
redirect_limit_
);
19
if
(this->
watchdog_timeout_
> 0) {
20
ESP_LOGCONFIG(TAG,
" Watchdog Timeout: %"
PRIu32
"ms"
, this->
watchdog_timeout_
);
21
}
22
}
23
24
std::string
HttpContainer::get_response_header
(
const
std::string &header_name) {
25
auto
lower =
str_lower_case
(header_name);
26
for
(
const
auto
&entry : this->
response_headers_
) {
27
if
(entry.name == lower) {
28
ESP_LOGD(TAG,
"Header with name %s found with value %s"
, lower.c_str(), entry.value.c_str());
29
return
entry.value;
30
}
31
}
32
ESP_LOGW(TAG,
"No header with name %s found"
, lower.c_str());
33
return
""
;
34
}
35
36
}
// namespace esphome::http_request
esphome::http_request::HttpContainer::get_response_header
std::string get_response_header(const std::string &header_name)
Definition
http_request.cpp:24
esphome::http_request::HttpContainer::response_headers_
std::vector< Header > response_headers_
Definition
http_request.h:276
esphome::http_request::HttpRequestComponent::timeout_
uint32_t timeout_
Definition
http_request.h:445
esphome::http_request::HttpRequestComponent::follow_redirects_
bool follow_redirects_
Definition
http_request.h:443
esphome::http_request::HttpRequestComponent::useragent_
const char * useragent_
Definition
http_request.h:442
esphome::http_request::HttpRequestComponent::redirect_limit_
uint16_t redirect_limit_
Definition
http_request.h:444
esphome::http_request::HttpRequestComponent::watchdog_timeout_
uint32_t watchdog_timeout_
Definition
http_request.h:446
esphome::http_request::HttpRequestComponent::dump_config
void dump_config() override
Definition
http_request.cpp:11
http_request.h
log.h
esphome::http_request
Definition
http_request.cpp:7
esphome::str_lower_case
std::string str_lower_case(const std::string &str)
Convert the string to lower case.
Definition
helpers.cpp:201
Generated by
1.12.0