[PATCH] Use RFC9110 HTTP status code descriptions

Maxim Dounin mdounin at mdounin.ru
Sat Apr 20 18:22:25 UTC 2024


Hello!

On Sun, Apr 14, 2024 at 12:26:23PM +0200, Michiel W. Beijen wrote:

> # HG changeset patch
> # User Michiel W. Beijen <mb at x14.nl>
> # Date 1713090220 -7200
> #      Sun Apr 14 12:23:40 2024 +0200
> # Branch stable-1.26
> # Node ID 3375171a24a16400b000805e45df1b57e4dd1775
> # Parent  cecfdf9a8420fcdeb69d090cd7fd9169967e0007
> Use RFC9110 HTTP status code descriptions

Nitpicking:

Updated HTTP status code descriptions to match RFC 9110.

> 
> This patch changes the status codes and status pages served by
> freenginx to use the wording from RFC9110

... RFC 9110.

> 
> Exeption for HTTP status code 413 "Request Entity Too Large",

Typo: "Exception...".

> which is "Content Too Large" in the RFC. In that case we would
> lose information about what actually is too large, the request
> or the response.
> 
> diff -r cecfdf9a8420 -r 3375171a24a1 src/http/ngx_http_header_filter_module.c
> --- a/src/http/ngx_http_header_filter_module.c	Sun Apr 14 12:03:29 2024 +0200
> +++ b/src/http/ngx_http_header_filter_module.c	Sun Apr 14 12:23:40 2024 +0200
> @@ -69,7 +69,7 @@
>      /* ngx_null_string, */  /* "300 Multiple Choices" */
>  
>      ngx_string("301 Moved Permanently"),
> -    ngx_string("302 Moved Temporarily"),
> +    ngx_string("302 Found"),

Looks good.

>      ngx_string("303 See Other"),
>      ngx_string("304 Not Modified"),
>      ngx_null_string,  /* "305 Use Proxy" */
> @@ -85,18 +85,18 @@
>      ngx_string("402 Payment Required"),
>      ngx_string("403 Forbidden"),
>      ngx_string("404 Not Found"),
> -    ngx_string("405 Not Allowed"),
> +    ngx_string("405 Method Not Allowed"),

Looks good.

Not sure where "Not Allowed" comes from, it seems to be written as 
"Method Not Allowed" since introduction in RFC 2068, as well as in 
Apache since at least 1.2.6.

>      ngx_string("406 Not Acceptable"),
>      ngx_null_string,  /* "407 Proxy Authentication Required" */
> -    ngx_string("408 Request Time-out"),
> +    ngx_string("408 Request Timeout"),

Looks good.

The "Time-out" spelling was used in some places in RFC 2068, where 
the code was introduced, and in RFC 2616 (notably, in section 
6.1.1 Status Code and Reason Phrase, 
https://datatracker.ietf.org/doc/html/rfc2616#section-6.1.1), 
while "Timeout" in other places (e.g., section 10.4.9 408 Request 
Timeout, 
https://datatracker.ietf.org/doc/html/rfc2616#section-10.4.9).  It 
was cleaned up in RFC 7231.

This is also the spelling Apache used till 2.4.3.

>      ngx_string("409 Conflict"),
>      ngx_string("410 Gone"),
>      ngx_string("411 Length Required"),
>      ngx_string("412 Precondition Failed"),
>      ngx_string("413 Request Entity Too Large"),
> -    ngx_string("414 Request-URI Too Large"),
> +    ngx_string("414 URI Too Long"),

Looks good, as previously discussed.

>      ngx_string("415 Unsupported Media Type"),
> -    ngx_string("416 Requested Range Not Satisfiable"),
> +    ngx_string("416 Range Not Satisfiable"),

Looks good.

The "416 Requested Range Not Satisfiable" error was introduced in 
RFC 2616, and was later updated to "416 Range Not Satisfiable" in
RFC 7233.

>      ngx_null_string,  /* "417 Expectation Failed" */
>      ngx_null_string,  /* "418 unused" */
>      ngx_null_string,  /* "419 unused" */
> @@ -117,8 +117,8 @@
>      ngx_string("500 Internal Server Error"),
>      ngx_string("501 Not Implemented"),
>      ngx_string("502 Bad Gateway"),
> -    ngx_string("503 Service Temporarily Unavailable"),
> -    ngx_string("504 Gateway Time-out"),
> +    ngx_string("503 Service Unavailable"),

Looks good.

The "503 Service Unavailable" form seems to exists since 
introduction of the code in RFC 1945.  The "503 Service 
Temporarily Unavailable" was used in Apache before 1.3.0 though.

> +    ngx_string("504 Gateway Timeout"),

Looks good.

The "504 Gateway Timeout" form is used since introduction of 
the code in RFC 1945, but similarly to the 408 error, "Time-out" 
spelling was used in Apache till 2.4.3.

Similarly to the 408 error, "Time-out" spelling was used in Apache 
till 2.4.3.

>      ngx_string("505 HTTP Version Not Supported"),
>      ngx_null_string,        /* "506 Variant Also Negotiates" */
>      ngx_string("507 Insufficient Storage"),
> diff -r cecfdf9a8420 -r 3375171a24a1 src/http/ngx_http_special_response.c
> --- a/src/http/ngx_http_special_response.c	Sun Apr 14 12:03:29 2024 +0200
> +++ b/src/http/ngx_http_special_response.c	Sun Apr 14 12:23:40 2024 +0200
> @@ -107,9 +107,9 @@
>  
>  static char ngx_http_error_401_page[] =
>  "<html>" CRLF
> -"<head><title>401 Authorization Required</title></head>" CRLF
> +"<head><title>401 Unauthorized</title></head>" CRLF
>  "<body>" CRLF
> -"<center><h1>401 Authorization Required</h1></center>" CRLF
> +"<center><h1>401 Unauthorized</h1></center>" CRLF
>  ;
>  
>  
> @@ -139,9 +139,9 @@
>  
>  static char ngx_http_error_405_page[] =
>  "<html>" CRLF
> -"<head><title>405 Not Allowed</title></head>" CRLF
> +"<head><title>405 Method Not Allowed</title></head>" CRLF
>  "<body>" CRLF
> -"<center><h1>405 Not Allowed</h1></center>" CRLF
> +"<center><h1>405 Method Not Allowed</h1></center>" CRLF
>  ;
>  
>  
> @@ -155,9 +155,9 @@
>  
>  static char ngx_http_error_408_page[] =
>  "<html>" CRLF
> -"<head><title>408 Request Time-out</title></head>" CRLF
> +"<head><title>408 Request Timeout</title></head>" CRLF
>  "<body>" CRLF
> -"<center><h1>408 Request Time-out</h1></center>" CRLF
> +"<center><h1>408 Request Timeout</h1></center>" CRLF
>  ;
>  
>  
> @@ -203,9 +203,9 @@
>  
>  static char ngx_http_error_414_page[] =
>  "<html>" CRLF
> -"<head><title>414 Request-URI Too Large</title></head>" CRLF
> +"<head><title>414 URI Too Long</title></head>" CRLF
>  "<body>" CRLF
> -"<center><h1>414 Request-URI Too Large</h1></center>" CRLF
> +"<center><h1>414 URI Too Long</h1></center>" CRLF
>  ;
>  
>  
> @@ -219,9 +219,9 @@
>  
>  static char ngx_http_error_416_page[] =
>  "<html>" CRLF
> -"<head><title>416 Requested Range Not Satisfiable</title></head>" CRLF
> +"<head><title>416 Range Not Satisfiable</title></head>" CRLF
>  "<body>" CRLF
> -"<center><h1>416 Requested Range Not Satisfiable</h1></center>" CRLF
> +"<center><h1>416 Range Not Satisfiable</h1></center>" CRLF
>  ;
>  
>  
> @@ -307,17 +307,17 @@
>  
>  static char ngx_http_error_503_page[] =
>  "<html>" CRLF
> -"<head><title>503 Service Temporarily Unavailable</title></head>" CRLF
> +"<head><title>503 Service Unavailable</title></head>" CRLF
>  "<body>" CRLF
> -"<center><h1>503 Service Temporarily Unavailable</h1></center>" CRLF
> +"<center><h1>503 Service Unavailable</h1></center>" CRLF
>  ;
>  
>  
>  static char ngx_http_error_504_page[] =
>  "<html>" CRLF
> -"<head><title>504 Gateway Time-out</title></head>" CRLF
> +"<head><title>504 Gateway Timeout</title></head>" CRLF
>  "<body>" CRLF
> -"<center><h1>504 Gateway Time-out</h1></center>" CRLF
> +"<center><h1>504 Gateway Timeout</h1></center>" CRLF
>  ;
>  
>  

Pushed with the mentioned commit log fixes and a patch for tests 
to remove dependencies on the particular 405 error text, thanks.

-- 
Maxim Dounin
http://mdounin.ru/



More information about the nginx-devel mailing list