MINOR: http: Add HTTP 501-not-implemented error message

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.
This commit is contained in:
Christopher Faulet 2020-12-07 11:22:24 +01:00
parent 7d013e796c
commit e095f31d36
3 changed files with 30 additions and 16 deletions

View File

@ -378,6 +378,8 @@ HAProxy may emit the following status codes by itself :
be available again be available again
500 when haproxy encounters an unrecoverable internal error, such as a 500 when haproxy encounters an unrecoverable internal error, such as a
memory allocation failure, which should never happen 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 502 when the server returns an empty, invalid or incomplete response, or
when an "http-response deny" rule blocks the response. when an "http-response deny" rule blocks the response.
503 when no server was available to handle the request, or in response to 503 when no server was available to handle the request, or in response to
@ -2911,7 +2913,7 @@ errorfile <code> <file>
Arguments : Arguments :
<code> is the HTTP status code. Currently, HAProxy is capable of <code> is the HTTP status code. Currently, HAProxy is capable of
generating codes 200, 400, 401, 403, 404, 405, 407, 408, 410, 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 <file> designates a file containing the full HTTP response. It is
recommended to follow the common practice of appending ".http" to recommended to follow the common practice of appending ".http" to
@ -4439,7 +4441,7 @@ errorfile <code> <file>
Arguments : Arguments :
<code> is the HTTP status code. Currently, HAProxy is capable of <code> is the HTTP status code. Currently, HAProxy is capable of
generating codes 200, 400, 401, 403, 404, 405, 407, 408, 410, 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 <file> designates a file containing the full HTTP response. It is
recommended to follow the common practice of appending ".http" to 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. <code> is a HTTP status code. Several status code may be listed.
Currently, HAProxy is capable of generating codes 200, 400, 401, 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 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 in the current proxy. If no status code is specified, all error files of the
@ -4514,7 +4517,7 @@ errorloc302 <code> <url>
Arguments : Arguments :
<code> is the HTTP status code. Currently, HAProxy is capable of <code> is the HTTP status code. Currently, HAProxy is capable of
generating codes 200, 400, 401, 403, 404, 405, 407, 408, 410, 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 <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, either a relative URI to an error page hosted on the same site,
@ -4546,7 +4549,7 @@ errorloc303 <code> <url>
Arguments : Arguments :
<code> is the HTTP status code. Currently, HAProxy is capable of <code> is the HTTP status code. Currently, HAProxy is capable of
generating codes 200, 400, 401, 403, 404, 405, 407, 408, 410, 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 <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, 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. status <code> is the HTTP status code. It must be specified.
Currently, HAProxy is capable of generating codes Currently, HAProxy is capable of generating codes
200, 400, 401, 403, 404, 405, 407, 408, 410, 413, 425, 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 content-type <type> is the response content type, for instance
"text/plain". This parameter is ignored and should be "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 * If "default-errorfiles" argument is set, the proxy's errorfiles are
considered. If the "status" argument is defined, it must be one of the 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, 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, 425, 429, 500, 501, 502, 503, and 504). The "content-type" argument, if
is ignored. any, is ignored.
* If a specific errorfile is defined, with an "errorfile" argument, the * If a specific errorfile is defined, with an "errorfile" argument, the
corresponding file, containing a full HTTP response, is returned. Only 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 "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, by haproxy (200, 400, 403, 404, 405, 408, 410, 413, 425, 429, 500, 501,
and 504). The "content-type" argument, if any, is ignored. 502, 503, and 504). The "content-type" argument, if any, is ignored.
* If an http-errors section is defined, with an "errorfiles" argument, the * If an http-errors section is defined, with an "errorfiles" argument, the
corresponding file in the specified http-errors section, containing a full corresponding file in the specified http-errors section, containing a full
HTTP response, is returned. Only the "status" argument is considered. It 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, 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. argument, if any, is ignored.
* If a "file" or a "lf-file" argument is specified, the file's content is * 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 * If "default-errorfiles" argument is set, the proxy's errorfiles are
considered. If the "status" argument is defined, it must be one of the 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, 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, 425, 429, 500, 501, 502, 503, and 504). The "content-type" argument, if
is ignored. any, is ignored.
* If a specific errorfile is defined, with an "errorfile" argument, the * If a specific errorfile is defined, with an "errorfile" argument, the
corresponding file, containing a full HTTP response, is returned. Only 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 "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, by haproxy (200, 400, 403, 404, 405, 408, 410, 413, 425, 429, 500, 501,
and 504). The "content-type" argument, if any, is ignored. 502, 503, and 504). The "content-type" argument, if any, is ignored.
* If an http-errors section is defined, with an "errorfiles" argument, the * If an http-errors section is defined, with an "errorfiles" argument, the
corresponding file in the specified http-errors section, containing a full corresponding file in the specified http-errors section, containing a full
HTTP response, is returned. Only the "status" argument is considered. It 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, 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. argument, if any, is ignored.
* If a "file" or a "lf-file" argument is specified, the file's content is * If a "file" or a "lf-file" argument is specified, the file's content is

View File

@ -95,6 +95,7 @@ enum {
HTTP_ERR_425, HTTP_ERR_425,
HTTP_ERR_429, HTTP_ERR_429,
HTTP_ERR_500, HTTP_ERR_500,
HTTP_ERR_501,
HTTP_ERR_502, HTTP_ERR_502,
HTTP_ERR_503, HTTP_ERR_503,
HTTP_ERR_504, HTTP_ERR_504,

View File

@ -170,6 +170,7 @@ const int http_err_codes[HTTP_ERR_SIZE] = {
[HTTP_ERR_425] = 425, [HTTP_ERR_425] = 425,
[HTTP_ERR_429] = 429, [HTTP_ERR_429] = 429,
[HTTP_ERR_500] = 500, [HTTP_ERR_500] = 500,
[HTTP_ERR_501] = 501,
[HTTP_ERR_502] = 502, [HTTP_ERR_502] = 502,
[HTTP_ERR_503] = 503, [HTTP_ERR_503] = 503,
[HTTP_ERR_504] = 504, [HTTP_ERR_504] = 504,
@ -290,6 +291,14 @@ const char *http_err_msgs[HTTP_ERR_SIZE] = {
"\r\n" "\r\n"
"<html><body><h1>500 Internal Server Error</h1>\nAn internal server error occurred.\n</body></html>\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_ERR_502] =
"HTTP/1.1 502 Bad Gateway\r\n" "HTTP/1.1 502 Bad Gateway\r\n"
"Content-length: 107\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 425: return HTTP_ERR_425;
case 429: return HTTP_ERR_429; case 429: return HTTP_ERR_429;
case 500: return HTTP_ERR_500; case 500: return HTTP_ERR_500;
case 501: return HTTP_ERR_501;
case 502: return HTTP_ERR_502; case 502: return HTTP_ERR_502;
case 503: return HTTP_ERR_503; case 503: return HTTP_ERR_503;
case 504: return HTTP_ERR_504; case 504: return HTTP_ERR_504;