Function esp_idf_sys::httpd_req_get_hdr_value_str

source ·
pub unsafe extern "C" fn httpd_req_get_hdr_value_str(
    r: *mut httpd_req_t,
    field: *const c_char,
    val: *mut c_char,
    val_size: usize,
) -> esp_err_t
Expand description

@brief Get the value string of a field from the request headers

@note

  • This API is supposed to be called only from the context of a URI handler where httpd_req_t* request pointer is valid.
  • Once httpd_resp_send() API is called all request headers are purged, so request headers need be copied into separate buffers if they are required later.
  • If output size is greater than input, then the value is truncated, accompanied by truncation error as return value.
  • Use httpd_req_get_hdr_value_len() to know the right buffer length

@param[in] r The request being responded to @param[in] field The field to be searched in the header @param[out] val Pointer to the buffer into which the value will be copied if the field is found @param[in] val_size Size of the user buffer “val”

@return

  • ESP_OK : Field found in the request header and value string copied
  • ESP_ERR_NOT_FOUND : Key not found
  • ESP_ERR_INVALID_ARG : Null arguments
  • ESP_ERR_HTTPD_INVALID_REQ : Invalid HTTP request pointer
  • ESP_ERR_HTTPD_RESULT_TRUNC : Value string truncated