[PATCH] Use RFC 9110 descriptions for status 413 and 414
Michiel W. Beijen
mb at x14.nl
Fri Apr 12 20:11:40 UTC 2024
# HG changeset patch
# User Michiel W. Beijen <mb at x14.nl>
# Date 1712950069 -7200
# Fri Apr 12 21:27:49 2024 +0200
# Node ID 58cd6cb2adba48ff9336c2896046e155074fdffd
# Parent ccd7e4022a2498a930c9e0927a9820f7ea17ae13
Use RFC 9110 descriptions for status 413 and 414
RFC 9110 is accepted as a Standards Track document in June 2022.
It obsoletes the earlier RFC 7231. It uses slightly different names for
HTTP status codes 413 and 414.
Rename the constants and documents returned by nginx to reflect the new
naming.
Keep the old constants in place for backwards compatibility.
ref: https://www.rfc-editor.org/rfc/rfc9110.html
diff -r ccd7e4022a24 -r 58cd6cb2adba src/http/modules/perl/nginx.pm
--- a/src/http/modules/perl/nginx.pm Tue Apr 02 20:55:21 2024 +0300
+++ b/src/http/modules/perl/nginx.pm Fri Apr 12 21:27:49 2024 +0200
@@ -37,7 +37,9 @@
HTTP_CONFLICT
HTTP_GONE
HTTP_LENGTH_REQUIRED
+ HTTP_CONTENT_TOO_LARGE
HTTP_REQUEST_ENTITY_TOO_LARGE
+ HTTP_URI_TOO_LONG
HTTP_REQUEST_URI_TOO_LARGE
HTTP_UNSUPPORTED_MEDIA_TYPE
HTTP_RANGE_NOT_SATISFIABLE
@@ -86,8 +88,8 @@
use constant HTTP_CONFLICT => 409;
use constant HTTP_GONE => 410;
use constant HTTP_LENGTH_REQUIRED => 411;
-use constant HTTP_REQUEST_ENTITY_TOO_LARGE => 413;
-use constant HTTP_REQUEST_URI_TOO_LARGE => 414;
+use constant HTTP_CONTENT_TOO_LARGE => 413;
+use constant HTTP_URI_TOO_LONG => 414;
use constant HTTP_UNSUPPORTED_MEDIA_TYPE => 415;
use constant HTTP_RANGE_NOT_SATISFIABLE => 416;
@@ -99,6 +101,10 @@
use constant HTTP_GATEWAY_TIME_OUT => 504;
use constant HTTP_INSUFFICIENT_STORAGE => 507;
+# For backwards compatibility
+use constant HTTP_REQUEST_ENTITY_TOO_LARGE => HTTP_CONTENT_TOO_LARGE;
+use constant HTTP_REQUEST_URI_TOO_LARGE => HTTP_URI_TOO_LONG;
+
sub rflush {
my $r = shift;
diff -r ccd7e4022a24 -r 58cd6cb2adba src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c Tue Apr 02 20:55:21 2024 +0300
+++ b/src/http/ngx_http_core_module.c Fri Apr 12 21:27:49 2024 +0200
@@ -993,7 +993,7 @@
r->expect_tested = 1;
(void) ngx_http_discard_request_body(r);
- ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE);
+ ngx_http_finalize_request(r, NGX_HTTP_CONTENT_TOO_LARGE);
return NGX_OK;
}
diff -r ccd7e4022a24 -r 58cd6cb2adba src/http/ngx_http_header_filter_module.c
--- a/src/http/ngx_http_header_filter_module.c Tue Apr 02 20:55:21 2024 +0300
+++ b/src/http/ngx_http_header_filter_module.c Fri Apr 12 21:27:49 2024 +0200
@@ -93,8 +93,8 @@
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("413 Content Too Large"),
+ ngx_string("414 URI Too Large"),
ngx_string("415 Unsupported Media Type"),
ngx_string("416 Requested Range Not Satisfiable"),
ngx_null_string, /* "417 Expectation Failed" */
diff -r ccd7e4022a24 -r 58cd6cb2adba src/http/ngx_http_request.c
--- a/src/http/ngx_http_request.c Tue Apr 02 20:55:21 2024 +0300
+++ b/src/http/ngx_http_request.c Fri Apr 12 21:27:49 2024 +0200
@@ -1232,7 +1232,7 @@
ngx_log_error(NGX_LOG_INFO, c->log, 0,
"client sent too long URI");
- ngx_http_finalize_request(r, NGX_HTTP_REQUEST_URI_TOO_LARGE);
+ ngx_http_finalize_request(r, NGX_HTTP_URI_TOO_LONG);
break;
}
}
diff -r ccd7e4022a24 -r 58cd6cb2adba src/http/ngx_http_request.h
--- a/src/http/ngx_http_request.h Tue Apr 02 20:55:21 2024 +0300
+++ b/src/http/ngx_http_request.h Fri Apr 12 21:27:49 2024 +0200
@@ -98,13 +98,16 @@
#define NGX_HTTP_CONFLICT 409
#define NGX_HTTP_LENGTH_REQUIRED 411
#define NGX_HTTP_PRECONDITION_FAILED 412
-#define NGX_HTTP_REQUEST_ENTITY_TOO_LARGE 413
-#define NGX_HTTP_REQUEST_URI_TOO_LARGE 414
+#define NGX_HTTP_CONTENT_TOO_LARGE 413
+#define NGX_HTTP_URI_TOO_LONG 414
#define NGX_HTTP_UNSUPPORTED_MEDIA_TYPE 415
#define NGX_HTTP_RANGE_NOT_SATISFIABLE 416
#define NGX_HTTP_MISDIRECTED_REQUEST 421
#define NGX_HTTP_TOO_MANY_REQUESTS 429
+/* For backwards compatibility*/
+#define NGX_HTTP_REQUEST_ENTITY_TOO_LARGE NGX_HTTP_CONTENT_TOO_LARGE
+#define NGX_HTTP_REQUEST_URI_TOO_LARGE NGX_HTTP_URI_TOO_LONG
/* Our own HTTP codes */
diff -r ccd7e4022a24 -r 58cd6cb2adba src/http/ngx_http_request_body.c
--- a/src/http/ngx_http_request_body.c Tue Apr 02 20:55:21 2024 +0300
+++ b/src/http/ngx_http_request_body.c Fri Apr 12 21:27:49 2024 +0200
@@ -1148,7 +1148,7 @@
r->lingering_close = 1;
- return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
+ return NGX_HTTP_CONTENT_TOO_LARGE;
}
if (clcf->client_max_body_size
@@ -1163,7 +1163,7 @@
r->lingering_close = 1;
- return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
+ return NGX_HTTP_CONTENT_TOO_LARGE;
}
if (b
@@ -1263,7 +1263,7 @@
r->lingering_close = 1;
- return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
+ return NGX_HTTP_CONTENT_TOO_LARGE;
}
/* set rb->rest, amount of data we want to see next time */
diff -r ccd7e4022a24 -r 58cd6cb2adba src/http/ngx_http_special_response.c
--- a/src/http/ngx_http_special_response.c Tue Apr 02 20:55:21 2024 +0300
+++ b/src/http/ngx_http_special_response.c Fri Apr 12 21:27:49 2024 +0200
@@ -195,17 +195,17 @@
static char ngx_http_error_413_page[] =
"<html>" CRLF
-"<head><title>413 Request Entity Too Large</title></head>" CRLF
+"<head><title>413 Content Too Large</title></head>" CRLF
"<body>" CRLF
-"<center><h1>413 Request Entity Too Large</h1></center>" CRLF
+"<center><h1>413 Content Too Large</h1></center>" CRLF
;
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
;
@@ -428,8 +428,8 @@
if (r->keepalive) {
switch (error) {
case NGX_HTTP_BAD_REQUEST:
- case NGX_HTTP_REQUEST_ENTITY_TOO_LARGE:
- case NGX_HTTP_REQUEST_URI_TOO_LARGE:
+ case NGX_HTTP_CONTENT_TOO_LARGE:
+ case NGX_HTTP_URI_TOO_LONG:
case NGX_HTTP_TO_HTTPS:
case NGX_HTTPS_CERT_ERROR:
case NGX_HTTPS_NO_CERT:
diff -r ccd7e4022a24 -r 58cd6cb2adba src/http/v2/ngx_http_v2.c
--- a/src/http/v2/ngx_http_v2.c Tue Apr 02 20:55:21 2024 +0300
+++ b/src/http/v2/ngx_http_v2.c Fri Apr 12 21:27:49 2024 +0200
@@ -4116,7 +4116,7 @@
"client intended to send too large chunked body: "
"%O bytes", rb->received);
- return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
+ return NGX_HTTP_CONTENT_TOO_LARGE;
}
}
diff -r ccd7e4022a24 -r 58cd6cb2adba src/http/v3/ngx_http_v3_request.c
--- a/src/http/v3/ngx_http_v3_request.c Tue Apr 02 20:55:21 2024 +0300
+++ b/src/http/v3/ngx_http_v3_request.c Fri Apr 12 21:27:49 2024 +0200
@@ -1581,7 +1581,7 @@
"body: %O+%ui bytes",
rb->received, st->length);
- return NGX_HTTP_REQUEST_ENTITY_TOO_LARGE;
+ return NGX_HTTP_CONTENT_TOO_LARGE;
}
continue;
More information about the nginx-devel
mailing list