2fa64334 by Ivan Grokhotkov

add function to get (request | form) argument values

1 parent fc44658b
......@@ -384,6 +384,17 @@ int http_request_get_method(http_context_t ctx)
return (int) ctx->parser.method;
}
const char* http_request_get_arg_value(http_context_t ctx, const char* name)
{
http_header_t* it;
SLIST_FOREACH(it, &ctx->request_args, list_entry) {
if (strcasecmp(name, it->name) == 0) {
return it->value;
}
}
return NULL;
}
esp_err_t http_request_get_data(http_context_t ctx, const char** out_data_ptr, size_t* out_size)
{
if (ctx->event != HTTP_HANDLE_DATA) {
......
......@@ -131,12 +131,12 @@ esp_err_t http_register_form_handler(http_server_t server, const char* uri_patte
int events, http_handler_fn_t callback, void* callback_arg);
/**
* @brief Get value for given form item name
* @brief Get value for given URL argument of form argument
* @param http_ctx context passed to the handler
* @param name name of form item
* @return pointer to the form item value, valid until the end of request
* @param name name of URL or form argument
* @return pointer to the value, valid until the end of request
*/
const char* http_request_get_form_value(http_context_t http_ctx, const char* name);
const char* http_request_get_arg_value(http_context_t http_ctx, const char* name);
/**
* @brief Get request method
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!