5 #include "http_parser.h" 10 namespace web_server_idf {
12 static const char *
const TAG =
"web_server_idf_utils";
16 for (; *str; str++, ptr++) {
19 if (
parse_hex(str, 2, reinterpret_cast<uint8_t *>(&buf), 1) == 2) {
26 }
else if (*str ==
'+') {
38 size_t len = httpd_req_get_hdr_value_len(req, name);
46 auto res = httpd_req_get_hdr_value_str(req, name, &str[0], len + 1);
55 auto len = httpd_req_get_url_query_len(req);
63 auto res = httpd_req_get_url_query_str(req, &str[0],
len + 1);
65 ESP_LOGW(TAG,
"Can't get query for request: %s", esp_err_to_name(res));
73 if (query_url.empty()) {
77 auto val = std::unique_ptr<char[]>(
new char[query_url.size()]);
79 ESP_LOGE(TAG,
"Not enough memory to the query key value");
83 if (httpd_query_key_value(query_url.c_str(), key.c_str(),
val.get(), query_url.size()) != ESP_OK) {
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.
optional< std::string > request_get_header(httpd_req_t *req, const char *name)
bool request_has_header(httpd_req_t *req, const char *name)
void url_decode(char *str)
optional< std::string > query_key_value(const std::string &query_url, const std::string &key)
optional< std::string > request_get_url_query(httpd_req_t *req)
Implementation of SPI Controller mode.