diff --git a/doc/configuration.txt b/doc/configuration.txt index 64b73501d..0c9cab60e 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -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 Arguments : 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. 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 Arguments : 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. 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 [ ...] 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 are imported in the current proxy. If no status code is specified, all error files of the @@ -4514,7 +4517,7 @@ errorloc302 Arguments : 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. 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 Arguments : 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. 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 [content-type ] status 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 is the response content type, for instance "text/plain". This parameter is ignored and should be @@ -5995,20 +5998,20 @@ http-request return [status ] [content-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 ] [content-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 diff --git a/include/haproxy/http-t.h b/include/haproxy/http-t.h index b809710b9..ab4756c11 100644 --- a/include/haproxy/http-t.h +++ b/include/haproxy/http-t.h @@ -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, diff --git a/src/http.c b/src/http.c index 8e38b0c62..689069ce1 100644 --- a/src/http.c +++ b/src/http.c @@ -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" "

500 Internal Server Error

\nAn internal server error occurred.\n\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" + "

501 Not Implemented

\n.The server does not support the functionality required to fulfill the request.\n\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;