Function esp_idf_hal::sys::httpd_send

source ·
pub unsafe extern "C" fn httpd_send(
    r: *mut httpd_req,
    buf: *const i8,
    buf_len: usize,
) -> i32
Expand description

@brief Raw HTTP send

Call this API if you wish to construct your custom response packet. When using this, all essential header, eg. HTTP version, Status Code, Content Type and Length, Encoding, etc. will have to be constructed manually, and HTTP delimeters (CRLF) will need to be placed correctly for separating sub-sections of the HTTP response packet.

If the send override function is set, this API will end up calling that function eventually to send data out.

@note

  • This API is supposed to be called only from the context of a URI handler where httpd_req_t* request pointer is valid.
  • Unless the response has the correct HTTP structure (which the user must now ensure) it is not guaranteed that it will be recognized by the client. For most cases, you wouldn’t have to call this API, but you would rather use either of : httpd_resp_send(), httpd_resp_send_chunk()

@param[in] r The request being responded to @param[in] buf Buffer from where the fully constructed packet is to be read @param[in] buf_len Length of the buffer

@return

  • Bytes : Number of bytes that were sent successfully
  • HTTPD_SOCK_ERR_INVALID : Invalid arguments
  • HTTPD_SOCK_ERR_TIMEOUT : Timeout/interrupted while calling socket send()
  • HTTPD_SOCK_ERR_FAIL : Unrecoverable error while calling socket send()