ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
utils.h
Go to the documentation of this file.
1#pragma once
2#ifdef USE_ESP32
3
4#include <esp_http_server.h>
5#include <string>
7
9
12size_t url_decode(char *str);
13
14bool request_has_header(httpd_req_t *req, const char *name);
15optional<std::string> request_get_header(httpd_req_t *req, const char *name);
16optional<std::string> query_key_value(const char *query_url, size_t query_len, const char *key);
17bool query_has_key(const char *query_url, size_t query_len, const char *key);
18
19// Helper function for case-insensitive character comparison
20inline bool char_equals_ci(char a, char b) { return ::tolower(a) == ::tolower(b); }
21
22// Helper function for case-insensitive string region comparison
23bool str_ncmp_ci(const char *s1, const char *s2, size_t n);
24
25// Bounded case-insensitive string search (like strcasestr but length-bounded)
26const char *strcasestr_n(const char *haystack, size_t haystack_len, const char *needle);
27
28} // namespace esphome::web_server_idf
29#endif // USE_ESP32
bool query_has_key(const char *query_url, size_t query_len, const char *key)
Definition utils.cpp:70
bool char_equals_ci(char a, char b)
Definition utils.h:20
optional< std::string > request_get_header(httpd_req_t *req, const char *name)
Definition utils.cpp:36
optional< std::string > query_key_value(const char *query_url, size_t query_len, const char *key)
Definition utils.cpp:53
const char * strcasestr_n(const char *haystack, size_t haystack_len, const char *needle)
Definition utils.cpp:93
bool str_ncmp_ci(const char *s1, const char *s2, size_t n)
Definition utils.cpp:83
size_t url_decode(char *str)
Decode URL-encoded string in-place (e.g., %20 -> space, + -> space) Returns the new length of the dec...
Definition utils.cpp:11
bool request_has_header(httpd_req_t *req, const char *name)
Definition utils.cpp:34