pub unsafe extern "C" fn httpd_resp_set_hdr(
    r: *mut httpd_req_t,
    field: *const c_char,
    value: *const c_char
) -> esp_err_t
Expand description

@brief API to append any additional headers

This API sets any additional header fields that need to be sent in the response.

@note

  • This API is supposed to be called only from the context of a URI handler where httpd_req_t* request pointer is valid.
  • The header isn’t sent out until any of the send APIs is executed.
  • The maximum allowed number of additional headers is limited to value of max_resp_headers in config structure.
  • Make sure that the lifetime of the field value strings are valid till send function is called.

@param[in] r The request being responded to @param[in] field The field name of the HTTP header @param[in] value The value of this HTTP header

@return

  • ESP_OK : On successfully appending new header
  • ESP_ERR_INVALID_ARG : Null arguments
  • ESP_ERR_HTTPD_RESP_HDR : Total additional headers exceed max allowed
  • ESP_ERR_HTTPD_INVALID_REQ : Invalid request pointer