Hello Tim, Am 1/8/20 um 1:21 PM schrieb Tim Düsterhus: > Please reference GitHub issue #80 in the commit message. > "See issue #80." would be sufficient. > >> + "<html><body><h1>410 Gone</h1></body></html>\n", > > Please add a description of the error message after the headline for > consistency with the other messages.
I fixed both issues and added a second patch implementing 404. Best regards, Florian
>From 38961d35696bd24b66815e4e09f78a8af3d0d021 Mon Sep 17 00:00:00 2001 From: Florian Tham <t...@fidion.de> Date: Wed, 8 Jan 2020 10:19:05 +0100 Subject: [PATCH 1/2] MINOR: http: Add 410 to http-request deny This patch adds http status code 410 Gone to http-request deny. See issue #80. --- doc/configuration.txt | 8 +++++--- include/common/http.h | 1 + src/http.c | 11 +++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/doc/configuration.txt b/doc/configuration.txt index 9bc7d7150..69daaa8b7 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -374,6 +374,8 @@ HAProxy may emit the following status codes by itself : accessing the stats page) 403 when a request is forbidden by a "http-request deny" rule 408 when the request timeout strikes before the request is complete + 410 when the requested resource is no longer available and will not + be available again 500 when haproxy encounters an unrecoverable internal error, such as a memory allocation failure, which should never happen 502 when the server returns an empty, invalid or incomplete response, or @@ -3605,7 +3607,7 @@ errorfile <code> <file> yes | yes | yes | yes Arguments : <code> is the HTTP status code. Currently, HAProxy is capable of - generating codes 200, 400, 403, 405, 408, 425, 429, 500, 502, + generating codes 200, 400, 403, 405, 408, 410, 425, 429, 500, 502, 503, and 504. <file> designates a file containing the full HTTP response. It is @@ -3654,7 +3656,7 @@ errorloc302 <code> <url> yes | yes | yes | yes Arguments : <code> is the HTTP status code. Currently, HAProxy is capable of - generating codes 200, 400, 403, 405, 408, 425, 429, 500, 502, + generating codes 200, 400, 403, 405, 408, 410, 425, 429, 500, 502, 503, and 504. <url> it is the exact contents of the "Location" header. It may contain @@ -3686,7 +3688,7 @@ errorloc303 <code> <url> yes | yes | yes | yes Arguments : <code> is the HTTP status code. Currently, HAProxy is capable of - generating codes 200, 400, 403, 405, 408, 425, 429, 500, 502, + generating codes 200, 400, 403, 405, 408, 410, 425, 429, 500, 502, 503, and 504. <url> it is the exact contents of the "Location" header. It may contain diff --git a/include/common/http.h b/include/common/http.h index 857c66e1d..2d9bad7ee 100644 --- a/include/common/http.h +++ b/include/common/http.h @@ -85,6 +85,7 @@ enum { HTTP_ERR_403, HTTP_ERR_405, HTTP_ERR_408, + HTTP_ERR_410, HTTP_ERR_421, HTTP_ERR_425, HTTP_ERR_429, diff --git a/src/http.c b/src/http.c index c9168669d..4f57a43bc 100644 --- a/src/http.c +++ b/src/http.c @@ -218,6 +218,7 @@ const int http_err_codes[HTTP_ERR_SIZE] = { [HTTP_ERR_403] = 403, [HTTP_ERR_405] = 405, [HTTP_ERR_408] = 408, + [HTTP_ERR_410] = 410, [HTTP_ERR_421] = 421, [HTTP_ERR_425] = 425, [HTTP_ERR_429] = 429, @@ -273,6 +274,15 @@ const char *http_err_msgs[HTTP_ERR_SIZE] = { "\r\n" "<html><body><h1>408 Request Time-out</h1>\nYour browser didn't send a complete request in time.\n</body></html>\n", + [HTTP_ERR_410] = + "HTTP/1.1 410 Gone\r\n" + "Content-length: 114\r\n" + "Cache-Control: no-cache\r\n" + "Connection: close\r\n" + "Content-Type: text/html\r\n" + "\r\n" + "<html><body><h1>410 Gone</h1>\nThe resource is no longer available and will not be available again.\n</body></html>\n", + [HTTP_ERR_421] = "HTTP/1.1 421 Misdirected Request\r\n" "Content-length: 104\r\n" @@ -379,6 +389,7 @@ int http_get_status_idx(unsigned int status) case 403: return HTTP_ERR_403; case 405: return HTTP_ERR_405; case 408: return HTTP_ERR_408; + case 410: return HTTP_ERR_410; case 421: return HTTP_ERR_421; case 425: return HTTP_ERR_425; case 429: return HTTP_ERR_429; -- 2.24.1
>From 86a8e1f4be02a713dbfd8e5704fc4c4eb2b3cd22 Mon Sep 17 00:00:00 2001 From: Florian Tham <t...@fidion.de> Date: Wed, 8 Jan 2020 13:35:30 +0100 Subject: [PATCH 2/2] MINOR: http: Add 404 to http-request deny This patch adds http status code 404 Not Found to http-request deny. See issue #80. --- doc/configuration.txt | 13 +++++++------ include/common/http.h | 1 + src/http.c | 11 +++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/doc/configuration.txt b/doc/configuration.txt index 69daaa8b7..d0bb97415 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -373,6 +373,7 @@ HAProxy may emit the following status codes by itself : 401 when an authentication is required to perform the action (when accessing the stats page) 403 when a request is forbidden by a "http-request deny" rule + 404 when the requested resource could not be found 408 when the request timeout strikes before the request is complete 410 when the requested resource is no longer available and will not be available again @@ -3607,8 +3608,8 @@ errorfile <code> <file> yes | yes | yes | yes Arguments : <code> is the HTTP status code. Currently, HAProxy is capable of - generating codes 200, 400, 403, 405, 408, 410, 425, 429, 500, 502, - 503, and 504. + generating codes 200, 400, 403, 404, 405, 408, 410, 425, 429, 500, + 502, 503, and 504. <file> designates a file containing the full HTTP response. It is recommended to follow the common practice of appending ".http" to @@ -3656,8 +3657,8 @@ errorloc302 <code> <url> yes | yes | yes | yes Arguments : <code> is the HTTP status code. Currently, HAProxy is capable of - generating codes 200, 400, 403, 405, 408, 410, 425, 429, 500, 502, - 503, and 504. + generating codes 200, 400, 403, 404, 405, 408, 410, 425, 429, 500, + 502, 503, and 504. <url> 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, @@ -3688,8 +3689,8 @@ errorloc303 <code> <url> yes | yes | yes | yes Arguments : <code> is the HTTP status code. Currently, HAProxy is capable of - generating codes 200, 400, 403, 405, 408, 410, 425, 429, 500, 502, - 503, and 504. + generating codes 200, 400, 403, 404, 405, 408, 410, 425, 429, 500, + 502, 503, and 504. <url> 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 2d9bad7ee..d3519bc11 100644 --- a/include/common/http.h +++ b/include/common/http.h @@ -83,6 +83,7 @@ enum { HTTP_ERR_200 = 0, HTTP_ERR_400, HTTP_ERR_403, + HTTP_ERR_404, HTTP_ERR_405, HTTP_ERR_408, HTTP_ERR_410, diff --git a/src/http.c b/src/http.c index 4f57a43bc..8e17bed0c 100644 --- a/src/http.c +++ b/src/http.c @@ -216,6 +216,7 @@ const int http_err_codes[HTTP_ERR_SIZE] = { [HTTP_ERR_200] = 200, /* used by "monitor-uri" */ [HTTP_ERR_400] = 400, [HTTP_ERR_403] = 403, + [HTTP_ERR_404] = 404, [HTTP_ERR_405] = 405, [HTTP_ERR_408] = 408, [HTTP_ERR_410] = 410, @@ -256,6 +257,15 @@ const char *http_err_msgs[HTTP_ERR_SIZE] = { "\r\n" "<html><body><h1>403 Forbidden</h1>\nRequest forbidden by administrative rules.\n</body></html>\n", + [HTTP_ERR_404] = + "HTTP/1.1 404 Not Found\r\n" + "Content-length: 83\r\n" + "Cache-Control: no-cache\r\n" + "Connection: close\r\n" + "Content-Type: text/html\r\n" + "\r\n" + "<html><body><h1>404 Not Found</h1>\nThe resource could not be found.\n</body></html>\n", + [HTTP_ERR_405] = "HTTP/1.1 405 Method Not Allowed\r\n" "Content-length: 146\r\n" @@ -387,6 +397,7 @@ int http_get_status_idx(unsigned int status) case 200: return HTTP_ERR_200; case 400: return HTTP_ERR_400; case 403: return HTTP_ERR_403; + case 404: return HTTP_ERR_404; case 405: return HTTP_ERR_405; case 408: return HTTP_ERR_408; case 410: return HTTP_ERR_410; -- 2.24.1