feat(http_server): add 413 Payload Too Large response

While not useful for the HTTP parser itself, this is very useful for
memory-limited consumers of the HTTP server API.

Signed-off-by: Harshit Malpani <harshit.malpani@espressif.com>
This commit is contained in:
Maciej Małecki
2024-05-05 13:43:20 +07:00
committed by Harshit Malpani
parent 3b771d7af2
commit e40b1402e4
2 changed files with 7 additions and 0 deletions

View File

@@ -608,6 +608,9 @@ typedef enum {
*/ */
HTTPD_411_LENGTH_REQUIRED, HTTPD_411_LENGTH_REQUIRED,
/* Incoming payload is too large */
HTTPD_413_CONTENT_TOO_LARGE,
/* URI length greater than CONFIG_HTTPD_MAX_URI_LEN */ /* URI length greater than CONFIG_HTTPD_MAX_URI_LEN */
HTTPD_414_URI_TOO_LONG, HTTPD_414_URI_TOO_LONG,

View File

@@ -432,6 +432,10 @@ esp_err_t httpd_resp_send_err(httpd_req_t *req, httpd_err_code_t error, const ch
status = "411 Length Required"; status = "411 Length Required";
msg = "Client must specify Content-Length"; msg = "Client must specify Content-Length";
break; break;
case HTTPD_413_CONTENT_TOO_LARGE:
status = "413 Content Too Large";
msg = "Content is too large";
break;
case HTTPD_431_REQ_HDR_FIELDS_TOO_LARGE: case HTTPD_431_REQ_HDR_FIELDS_TOO_LARGE:
status = "431 Request Header Fields Too Large"; status = "431 Request Header Fields Too Large";
msg = "Header fields are too long"; msg = "Header fields are too long";