http: Function to get Cookie value from request.

Closes https://github.com/espressif/esp-idf/pull/7273

Signed-off-by: Shubham Kulkarni <shubham.kulkarni@espressif.com>
This commit is contained in:
Patryk Krzywdziński
2021-07-12 10:26:41 +02:00
committed by bot
parent f5266c1066
commit f43e9cdaa7
2 changed files with 107 additions and 0 deletions

View File

@@ -941,6 +941,24 @@ esp_err_t httpd_req_get_url_query_str(httpd_req_t *r, char *buf, size_t buf_len)
*/
esp_err_t httpd_query_key_value(const char *qry, const char *key, char *val, size_t val_size);
/**
* @brief Get the value string of a cookie value from the "Cookie" request headers by cookie name.
*
* @param[in] req Pointer to the HTTP request
* @param[in] cookie_name The cookie name to be searched in the request
* @param[out] val Pointer to the buffer into which the value of cookie will be copied if the cookie is found
* @param[inout] val_size Pointer to size of the user buffer "val". This variable will contain cookie length if
* ESP_OK is returned and required buffer length incase ESP_ERR_HTTPD_RESULT_TRUNC is returned.
*
* @return
* - ESP_OK : Key is found in the cookie string and copied to buffer
* - ESP_ERR_NOT_FOUND : Key not found
* - ESP_ERR_INVALID_ARG : Null arguments
* - ESP_ERR_HTTPD_RESULT_TRUNC : Value string truncated
* - ESP_ERR_NO_MEM : Memory allocation failure
*/
esp_err_t httpd_req_get_cookie_val(httpd_req_t *req, const char *cookie_name, char *val, size_t *val_size);
/**
* @brief Test if a URI matches the given wildcard template.
*