Chapter 2. API Reference
• 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
Parameters
• [in] r: The request being responded to
• [in] str: String to be sent as response body
static esp_err_t httpd_resp_sendstr_chunk(httpd_req_t *r, const char *str)
API to send a string as an HTTP response chunk.
This API simply calls http_resp_send_chunk with buffer length set to string length assuming the buffer contains
a null terminated string
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
Parameters
• [in] r: The request being responded to
• [in] str: String to be sent as response body (NULL to finish response packet)
esp_err_t httpd_resp_set_status(httpd_req_t *r, const char *status)
API to set the HTTP status code.
This API sets the status of the HTTP response to the value specified. By default, the ‘200 OK’response is
sent as 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.
• This API only sets the status to this value. The status isn’t sent out until any of the send APIs is
executed.
• Make sure that the lifetime of the status string is valid till send function is called.
Return
• ESP_OK : On success
• ESP_ERR_INVALID_ARG : Null arguments
• ESP_ERR_HTTPD_INVALID_REQ : Invalid request pointer
Parameters
• [in] r: The request being responded to
• [in] status: The HTTP status code of this response
esp_err_t httpd_resp_set_type(httpd_req_t *r, const char *type)
API to set the HTTP content type.
This API sets the ‘Content Type’field of the response. The default content type is ‘text/html’.
Note
• This API is supposed to be called only from the context of a URI handler where httpd_req_t* request
pointer is valid.
• This API only sets the content type to this value. The type isn’t sent out until any of the send APIs
is executed.
• Make sure that the lifetime of the type string is valid till send function is called.
Return
• ESP_OK : On success
• ESP_ERR_INVALID_ARG : Null arguments
• ESP_ERR_HTTPD_INVALID_REQ : Invalid request pointer
Parameters
• [in] r: The request being responded to
• [in] type: The Content Type of the response
Espressif Systems 580
Submit Document Feedback
Release v4.4