5#include "http_parser.h"
14 for (; *str; str++, ptr++) {
17 if (
parse_hex(str, 2,
reinterpret_cast<uint8_t *
>(&buf), 1) == 2) {
24 }
else if (*str ==
'+') {
34bool request_has_header(httpd_req_t *req,
const char *name) {
return httpd_req_get_hdr_value_len(req, name); }
37 size_t len = httpd_req_get_hdr_value_len(req, name);
45 auto res = httpd_req_get_hdr_value_str(req, name, &str[0],
len + 1);
54 if (query_url ==
nullptr || query_len == 0) {
62 if (httpd_query_key_value(query_url, key,
val.get(), query_len) != ESP_OK) {
70bool query_has_key(
const char *query_url,
size_t query_len,
const char *key) {
71 if (query_url ==
nullptr || query_len == 0) {
78 auto err = httpd_query_key_value(query_url, key, buf,
sizeof(buf));
79 return err == ESP_OK || err == ESP_ERR_HTTPD_RESULT_TRUNC;
84 for (
size_t i = 0; i < n; i++) {
93const char *
strcasestr_n(
const char *haystack,
size_t haystack_len,
const char *needle) {
98 size_t needle_len = strlen(needle);
99 if (needle_len == 0) {
103 if (haystack_len < needle_len) {
107 const char *
end = haystack + haystack_len - needle_len + 1;
108 for (
const char *p = haystack; p <
end; p++) {
Helper class for efficient buffer allocation - uses stack for small sizes, heap for large This is use...
bool query_has_key(const char *query_url, size_t query_len, const char *key)
bool char_equals_ci(char a, char b)
optional< std::string > request_get_header(httpd_req_t *req, const char *name)
optional< std::string > query_key_value(const char *query_url, size_t query_len, const char *key)
const char * strcasestr_n(const char *haystack, size_t haystack_len, const char *needle)
bool str_ncmp_ci(const char *s1, const char *s2, size_t n)
size_t url_decode(char *str)
Decode URL-encoded string in-place (e.g., %20 -> space, + -> space) Returns the new length of the dec...
bool request_has_header(httpd_req_t *req, const char *name)
size_t parse_hex(const char *str, size_t length, uint8_t *data, size_t count)
Parse bytes from a hex-encoded string into a byte array.