Function esp_idf_sys::httpd_req_get_url_query_str

source ·
pub unsafe extern "C" fn httpd_req_get_url_query_str(
    r: *mut httpd_req_t,
    buf: *mut c_char,
    buf_len: usize,
) -> esp_err_t
Expand description

@brief Get Query string from the request URL

@note

  • Presently, the user can fetch the full URL query string, but decoding will have to be performed by the user. Request headers can be read using httpd_req_get_hdr_value_str() to know the ‘Content-Type’ (eg. Content-Type: application/x-www-form-urlencoded) and then the appropriate decoding algorithm needs to be applied.
  • This API is supposed to be called only from the context of a URI handler where httpd_req_t* request pointer is valid
  • If output size is greater than input, then the value is truncated, accompanied by truncation error as return value
  • Prior to calling this function, one can use httpd_req_get_url_query_len() to know the query string length beforehand and hence allocate the buffer of right size (usually query string length + 1 for null termination) for storing the query string

@param[in] r The request being responded to @param[out] buf Pointer to the buffer into which the query string will be copied (if found) @param[in] buf_len Length of output buffer

@return

  • ESP_OK : Query is found in the request URL and copied to buffer
  • ESP_ERR_NOT_FOUND : Query not found
  • ESP_ERR_INVALID_ARG : Null arguments
  • ESP_ERR_HTTPD_INVALID_REQ : Invalid HTTP request pointer
  • ESP_ERR_HTTPD_RESULT_TRUNC : Query string truncated