From: Anthonin Bonnefoy Date: Mon, 22 Jun 2020 07:17:01 +0000 (+0200) Subject: MINOR: http: Add support for http 413 status X-Git-Tag: v2.1.8~37 X-Git-Url: http://git.haproxy.org/?a=commitdiff_plain;h=ce7e8f6ead075743603475b3964919c6ec9fb8a3;p=haproxy-2.1.git MINOR: http: Add support for http 413 status Add 413 http "payload too large" status code. This will allow 413 to be used in deny_status and errorfile. (cherry picked from commit 85048f80c9c1ca22732951e83c01ab0b31f5371f) Signed-off-by: Christopher Faulet [Cf: A "connection: close" has been added in the HTTP message to be consistent with other error codes] --- diff --git a/doc/configuration.txt b/doc/configuration.txt index d2e7f3e..bf55f90 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -3601,8 +3601,8 @@ errorfile yes | yes | yes | yes Arguments : is the HTTP status code. Currently, HAProxy is capable of - generating codes 200, 400, 403, 404, 405, 408, 410, 425, 429, 500, - 502, 503, and 504. + generating codes 200, 400, 403, 404, 405, 408, 410, 413, 425, 429, + 500, 502, 503, and 504. designates a file containing the full HTTP response. It is recommended to follow the common practice of appending ".http" to @@ -3650,8 +3650,8 @@ errorloc302 yes | yes | yes | yes Arguments : is the HTTP status code. Currently, HAProxy is capable of - generating codes 200, 400, 403, 404, 405, 408, 410, 425, 429, 500, - 502, 503, and 504. + generating codes 200, 400, 403, 404, 405, 408, 410, 413, 425, 429, + 500, 502, 503, and 504. it is the exact contents of the "Location" header. It may contain either a relative URI to an error page hosted on the same site, @@ -3682,8 +3682,8 @@ errorloc303 yes | yes | yes | yes Arguments : is the HTTP status code. Currently, HAProxy is capable of - generating codes 200, 400, 403, 404, 405, 408, 410, 425, 429, 500, - 502, 503, and 504. + generating codes 200, 400, 403, 404, 405, 408, 410, 413, 425, 429, + 500, 502, 503, and 504. it is the exact contents of the "Location" header. It may contain either a relative URI to an error page hosted on the same site, diff --git a/include/common/http.h b/include/common/http.h index d3519bc..db0c3ac 100644 --- a/include/common/http.h +++ b/include/common/http.h @@ -87,6 +87,7 @@ enum { HTTP_ERR_405, HTTP_ERR_408, HTTP_ERR_410, + HTTP_ERR_413, HTTP_ERR_421, HTTP_ERR_425, HTTP_ERR_429, diff --git a/src/http.c b/src/http.c index 8e17bed..cdd8af3 100644 --- a/src/http.c +++ b/src/http.c @@ -220,6 +220,7 @@ const int http_err_codes[HTTP_ERR_SIZE] = { [HTTP_ERR_405] = 405, [HTTP_ERR_408] = 408, [HTTP_ERR_410] = 410, + [HTTP_ERR_413] = 413, [HTTP_ERR_421] = 421, [HTTP_ERR_425] = 425, [HTTP_ERR_429] = 429, @@ -293,6 +294,15 @@ const char *http_err_msgs[HTTP_ERR_SIZE] = { "\r\n" "

410 Gone

\nThe resource is no longer available and will not be available again.\n\n", + [HTTP_ERR_413] = + "HTTP/1.1 413 Payload Too Large\r\n" + "Content-length: 106\r\n" + "Cache-Control: no-cache\r\n" + "Connection: close\r\n" + "Content-Type: text/html\r\n" + "\r\n" + "

413 Payload Too Large

\nThe request entity exceeds the maximum allowed.\n\n", + [HTTP_ERR_421] = "HTTP/1.1 421 Misdirected Request\r\n" "Content-length: 104\r\n" @@ -401,6 +411,7 @@ int http_get_status_idx(unsigned int status) case 405: return HTTP_ERR_405; case 408: return HTTP_ERR_408; case 410: return HTTP_ERR_410; + case 413: return HTTP_ERR_413; case 421: return HTTP_ERR_421; case 425: return HTTP_ERR_425; case 429: return HTTP_ERR_429;