Skip to content

Commit

Permalink
feat(http_server): add 413 Payload Too Large response
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
mmalecki authored and hmalpani committed May 29, 2024
1 parent 3b771d7 commit e40b140
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions components/esp_http_server/include/esp_http_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ typedef enum {
*/
HTTPD_411_LENGTH_REQUIRED,

/* Incoming payload is too large */
HTTPD_413_CONTENT_TOO_LARGE,

/* URI length greater than CONFIG_HTTPD_MAX_URI_LEN */
HTTPD_414_URI_TOO_LONG,

Expand Down
4 changes: 4 additions & 0 deletions components/esp_http_server/src/httpd_txrx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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";
msg = "Client must specify Content-Length";
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:
status = "431 Request Header Fields Too Large";
msg = "Header fields are too long";
Expand Down

0 comments on commit e40b140

Please sign in to comment.