Function esp_idf_sys::httpd_resp_send

source ยท
pub unsafe extern "C" fn httpd_resp_send(
    r: *mut httpd_req_t,
    buf: *const c_char,
    buf_len: isize,
) -> esp_err_t
Expand description

@brief API to send a complete HTTP response.

This API will send the data as an HTTP response to the request. This assumes that you have the entire response ready in a single buffer. If you wish to send response in incremental chunks use httpd_resp_send_chunk() instead.

If no status code and content-type were set, by default this will send 200 OK status code and content type as text/html. You may call the following functions before this API to configure the response headers : httpd_resp_set_status() - for setting the HTTP status string, httpd_resp_set_type() - for setting the Content Type, httpd_resp_set_hdr() - for appending any additional field value entries in the response header

@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 this API is called, the request has been responded to.
  • No additional data can then be sent for the request.
  • Once this API is called, all request headers are purged, so request headers need be copied into separate buffers if they are required later.

@param[in] r The request being responded to @param[in] buf Buffer from where the content is to be fetched @param[in] buf_len Length of the buffer, HTTPD_RESP_USE_STRLEN to use strlen()

@return

  • ESP_OK : On successfully sending the response packet
  • ESP_ERR_INVALID_ARG : Null request pointer
  • ESP_ERR_HTTPD_RESP_HDR : Essential headers are too large for internal buffer
  • ESP_ERR_HTTPD_RESP_SEND : Error in raw send
  • ESP_ERR_HTTPD_INVALID_REQ : Invalid request