]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http: Add 410 to http-request deny
authorFlorian Tham <tham@fidion.de>
Wed, 8 Jan 2020 09:19:05 +0000 (10:19 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 8 Jan 2020 15:15:23 +0000 (16:15 +0100)
This patch adds http status code 410 Gone to http-request deny. See
issue #80.

doc/configuration.txt
include/common/http.h
src/http.c

index 9bc7d7150b4f0a1d3b73aab0dfb55413267b57a7..69daaa8b76a3ea424c5c680ec53713d07c96f27c 100644 (file)
@@ -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
index 857c66e1d45c9a7e4a6f24a54e236bd3a39bb607..2d9bad7eebc5984f7e751cce653012a145a4bb64 100644 (file)
@@ -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,
index c9168669db22c2fd0307672b8c77c5f3fbfc3945..4f57a43bc4dabc83aed2b646d83947dcdf3fa21f 100644 (file)
@@ -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;