Function esp_idf_hal::sys::httpd_req_recv
source · pub unsafe extern "C" fn httpd_req_recv(
r: *mut httpd_req,
buf: *mut i8,
buf_len: usize,
) -> i32
Expand description
@brief API to read content data from the HTTP request
This API will read HTTP content data from the HTTP request into provided buffer. Use content_len provided in httpd_req_t structure to know the length of data to be fetched. If content_len is too large for the buffer then user may have to make multiple calls to this function, each time fetching ‘buf_len’ number of bytes, while the pointer to content data is incremented internally by the same number.
@note
- This API is supposed to be called only from the context of a URI handler where httpd_req_t* request pointer is valid.
- If an error is returned, the URI handler must further return an error. This will ensure that the erroneous socket is closed and cleaned up by the web server.
- Presently Chunked Encoding is not supported
@param[in] r The request being responded to @param[in] buf Pointer to a buffer that the data will be read into @param[in] buf_len Length of the buffer
@return
- Bytes : Number of bytes read into the buffer successfully
- 0 : Buffer length parameter is zero / connection closed by peer
- HTTPD_SOCK_ERR_INVALID : Invalid arguments
- HTTPD_SOCK_ERR_TIMEOUT : Timeout/interrupted while calling socket recv()
- HTTPD_SOCK_ERR_FAIL : Unrecoverable error while calling socket recv()