]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: http: Add HTTP 501-not-implemented error message
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 7 Dec 2020 10:22:24 +0000 (11:22 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Thu, 21 Jan 2021 14:21:12 +0000 (15:21 +0100)
Add the support for the 501-not-implemented status code with the
corresponding default message. The documentation is updated accordingly
because it is now part of status codes HAProxy may emit via an errorfile or
a deny/return HTTP action.

doc/configuration.txt
include/haproxy/http-t.h
src/http.c

index 64b73501d22ca56760d3d4a73f7fe2ee37891a27..0c9cab60ed351a5a123d3872f5e1c1280a5e427c 100644 (file)
@@ -378,6 +378,8 @@ HAProxy may emit the following status codes by itself :
         be available again
    500  when haproxy encounters an unrecoverable internal error, such as a
         memory allocation failure, which should never happen
+   501 when haproxy is unable to satisfy a client request because of an
+       unsupported feature
    502  when the server returns an empty, invalid or incomplete response, or
         when an "http-response deny" rule blocks the response.
    503  when no server was available to handle the request, or in response to
@@ -2911,7 +2913,7 @@ errorfile <code> <file>
   Arguments :
     <code>    is the HTTP status code. Currently, HAProxy is capable of
               generating codes 200, 400, 401, 403, 404, 405, 407, 408, 410,
-              425, 429, 500, 502, 503, and 504.
+              425, 429, 500, 501, 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
@@ -4439,7 +4441,7 @@ errorfile <code> <file>
   Arguments :
     <code>    is the HTTP status code. Currently, HAProxy is capable of
               generating codes 200, 400, 401, 403, 404, 405, 407, 408, 410,
-              413, 425, 429, 500, 502, 503, and 504.
+              413, 425, 429, 500, 501, 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
@@ -4488,7 +4490,8 @@ errorfiles <name> [<code> ...]
 
     <code>  is a HTTP status code. Several status code may be listed.
             Currently, HAProxy is capable of generating codes 200, 400, 401,
-            403, 404, 405, 407, 408, 410, 413, 425, 429, 500, 502, 503, and 504.
+            403, 404, 405, 407, 408, 410, 413, 425, 429, 500, 501, 502, 503,
+            and 504.
 
   Errors defined in the http-errors section with the name <name> are imported
   in the current proxy. If no status code is specified, all error files of the
@@ -4514,7 +4517,7 @@ errorloc302 <code> <url>
   Arguments :
     <code>    is the HTTP status code. Currently, HAProxy is capable of
               generating codes 200, 400, 401, 403, 404, 405, 407, 408, 410,
-              413, 425, 429, 500, 502, 503, and 504.
+              413, 425, 429, 500, 501, 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,
@@ -4546,7 +4549,7 @@ errorloc303 <code> <url>
   Arguments :
     <code>    is the HTTP status code. Currently, HAProxy is capable of
               generating codes 200, 400, 401, 403, 404, 405, 407, 408, 410,
-              413, 425, 429, 500, 502, 503, and 504.
+              413, 425, 429, 500, 501, 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,
@@ -5532,7 +5535,7 @@ http-error status <code> [content-type <type>]
     status <code>        is the HTTP status code. It must be specified.
                          Currently, HAProxy is capable of generating codes
                          200, 400, 401, 403, 404, 405, 407, 408, 410, 413, 425,
-                         429, 500, 502, 503, and 504.
+                         429, 500, 501, 502, 503, and 504.
 
     content-type <type>  is the response content type, for instance
                          "text/plain". This parameter is ignored and should be
@@ -5995,20 +5998,20 @@ http-request return [status <code>] [content-type <type>]
   * If "default-errorfiles" argument is set, the proxy's errorfiles are
     considered.  If the "status" argument is defined, it must be one of the
     status code handled by haproxy (200, 400, 403, 404, 405, 408, 410, 413,
-    425, 429, 500, 502, 503, and 504). The "content-type" argument, if any,
-    is ignored.
+    425, 429, 500, 501, 502, 503, and 504). The "content-type" argument, if
+    any, is ignored.
 
   * If a specific errorfile is defined, with an "errorfile" argument, the
     corresponding file, containing a full HTTP response, is returned. Only the
     "status" argument is considered. It must be one of the status code handled
-    by haproxy (200, 400, 403, 404, 405, 408, 410, 413, 425, 429, 500, 502, 503,
-    and 504). The "content-type" argument, if any, is ignored.
+    by haproxy (200, 400, 403, 404, 405, 408, 410, 413, 425, 429, 500, 501,
+    502, 503, and 504). The "content-type" argument, if any, is ignored.
 
   * If an http-errors section is defined, with an "errorfiles" argument, the
     corresponding file in the specified http-errors section, containing a full
     HTTP response, is returned. Only the "status" argument is considered. It
     must be one of the status code handled by haproxy (200, 400, 403, 404, 405,
-    408, 410, 413, 425, 429, 500, 502, 503, and 504). The "content-type"
+    408, 410, 413, 425, 429, 500, 501, 502, 503, and 504). The "content-type"
     argument, if any, is ignored.
 
   * If a "file" or a "lf-file" argument is specified, the file's content is
@@ -6670,20 +6673,20 @@ http-response return [status <code>] [content-type <type>]
   * If "default-errorfiles" argument is set, the proxy's errorfiles are
     considered.  If the "status" argument is defined, it must be one of the
     status code handled by haproxy (200, 400, 403, 404, 405, 408, 410, 413,
-    425, 429, 500, 502, 503, and 504). The "content-type" argument, if any,
-    is ignored.
+    425, 429, 500, 501, 502, 503, and 504). The "content-type" argument, if
+    any, is ignored.
 
   * If a specific errorfile is defined, with an "errorfile" argument, the
     corresponding file, containing a full HTTP response, is returned. Only the
     "status" argument is considered. It must be one of the status code handled
-    by haproxy (200, 400, 403, 404, 405, 408, 410, 413, 425, 429, 500, 502, 503,
-    and 504). The "content-type" argument, if any, is ignored.
+    by haproxy (200, 400, 403, 404, 405, 408, 410, 413, 425, 429, 500, 501,
+    502, 503, and 504). The "content-type" argument, if any, is ignored.
 
   * If an http-errors section is defined, with an "errorfiles" argument, the
     corresponding file in the specified http-errors section, containing a full
     HTTP response, is returned. Only the "status" argument is considered. It
     must be one of the status code handled by haproxy (200, 400, 403, 404, 405,
-    408, 410, 413, 425, 429, 500, 502, 503, and 504). The "content-type"
+    408, 410, 413, 425, 429, 500, 501, 502, 503, and 504). The "content-type"
     argument, if any, is ignored.
 
   * If a "file" or a "lf-file" argument is specified, the file's content is
index b809710b96cfd980436ee6083c35d4b321fa3693..ab4756c117bced09bdf65fce441584c7fb8d61e8 100644 (file)
@@ -95,6 +95,7 @@ enum {
        HTTP_ERR_425,
        HTTP_ERR_429,
        HTTP_ERR_500,
+       HTTP_ERR_501,
        HTTP_ERR_502,
        HTTP_ERR_503,
        HTTP_ERR_504,
index 8e38b0c629ced63725bf2e66bba5dcb60c8fdccf..689069ce149ed3906c228c144c10d1e68b342135 100644 (file)
@@ -170,6 +170,7 @@ const int http_err_codes[HTTP_ERR_SIZE] = {
        [HTTP_ERR_425] = 425,
        [HTTP_ERR_429] = 429,
        [HTTP_ERR_500] = 500,
+       [HTTP_ERR_501] = 501,
        [HTTP_ERR_502] = 502,
        [HTTP_ERR_503] = 503,
        [HTTP_ERR_504] = 504,
@@ -290,6 +291,14 @@ const char *http_err_msgs[HTTP_ERR_SIZE] = {
        "\r\n"
        "<html><body><h1>500 Internal Server Error</h1>\nAn internal server error occurred.\n</body></html>\n",
 
+       [HTTP_ERR_501] =
+       "HTTP/1.1 501 Not Implemented\r\n"
+       "Content-length: 136\r\n"
+       "Cache-Control: no-cache\r\n"
+       "Content-Type: text/html\r\n"
+       "\r\n"
+       "<html><body><h1>501 Not Implemented</h1>\n.The server does not support the functionality required to fulfill the request.\n</body></html>\n",
+
        [HTTP_ERR_502] =
        "HTTP/1.1 502 Bad Gateway\r\n"
        "Content-length: 107\r\n"
@@ -365,6 +374,7 @@ int http_get_status_idx(unsigned int status)
        case 425: return HTTP_ERR_425;
        case 429: return HTTP_ERR_429;
        case 500: return HTTP_ERR_500;
+       case 501: return HTTP_ERR_501;
        case 502: return HTTP_ERR_502;
        case 503: return HTTP_ERR_503;
        case 504: return HTTP_ERR_504;