EasyManua.ls Logo

Espressif ESP32-S2 - Page 592

Espressif ESP32-S2
1695 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
esp_err_t httpd_resp_set_hdr(httpd_req_t *r, const char *field, const char *value)
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.
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
Parameters
• [in] r: The request being responded to
• [in] field: The field name of the HTTP header
• [in] value: The value of this HTTP header
esp_err_t httpd_resp_send_err(httpd_req_t *req, httpd_err_code_t error, const char *msg)
For sending out error code in response to HTTP request.
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, all request headers are purged, so request headers need be copied into
separate buffers if they are required later.
• If you wish to send additional data in the body of the response, please use the lower-level functions
directly.
Return
• ESP_OK : On successfully sending the response packet
• ESP_ERR_INVALID_ARG : Null arguments
• ESP_ERR_HTTPD_RESP_SEND : Error in raw send
• ESP_ERR_HTTPD_INVALID_REQ : Invalid request pointer
Parameters
• [in] req: Pointer to the HTTP request for which the response needs to be sent
• [in] error: Error type to send
• [in] msg: Error message string (pass NULL for default message)
static esp_err_t httpd_resp_send_404(httpd_req_t *r)
Helper function for HTTP 404.
Send HTTP 404 message. If you wish to send additional data in the body of the response, please use the
lower-level functions directly.
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, all request headers are purged, so request headers need be copied into
separate buffers if they are required later.
Return
• ESP_OK : On successfully sending the response packet
• ESP_ERR_INVALID_ARG : Null arguments
• ESP_ERR_HTTPD_RESP_SEND : Error in raw send
• ESP_ERR_HTTPD_INVALID_REQ : Invalid request pointer
Parameters
• [in] r: The request being responded to
static esp_err_t httpd_resp_send_408(httpd_req_t *r)
Espressif Systems 581
Submit Document Feedback
Release v4.4

Table of Contents