Welcome! Log In Create A New Profile

Advanced

[PATCH 1 of 3] HTTP: add support for "429 Too Many Requests" response (RFC6585)

Piotr Sikora via nginx-devel
February 28, 2017 06:42PM
# HG changeset patch
# User Piotr Sikora <piotrsikora@google.com>
# Date 1488324535 28800
# Tue Feb 28 15:28:55 2017 -0800
# Node ID 9a63d6e990d230db0ec6b03250265447f648526e
# Parent 8b7fd958c59f8280d167fe7dd93f1942bfed5876
HTTP: add support for "429 Too Many Requests" response (RFC6585).

This change adds reason phrase in status line and pretty response body
when "429" status code is used in "return", "limit_conn_status" and/or
"limit_req_status" directives.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>

diff -r 8b7fd958c59f -r 9a63d6e990d2 src/http/ngx_http_header_filter_module.c
--- a/src/http/ngx_http_header_filter_module.c
+++ b/src/http/ngx_http_header_filter_module.c
@@ -101,12 +101,16 @@ static ngx_str_t ngx_http_status_lines[]
ngx_null_string, /* "419 unused" */
ngx_null_string, /* "420 unused" */
ngx_string("421 Misdirected Request"),
+ ngx_null_string, /* "422 Unprocessable Entity" */
+ ngx_null_string, /* "423 Locked" */
+ ngx_null_string, /* "424 Failed Dependency" */
+ ngx_null_string, /* "425 unused" */
+ ngx_null_string, /* "426 Upgrade Required" */
+ ngx_null_string, /* "427 unused" */
+ ngx_null_string, /* "428 Precondition Required" */
+ ngx_string("429 Too Many Requests"),

- /* ngx_null_string, */ /* "422 Unprocessable Entity" */
- /* ngx_null_string, */ /* "423 Locked" */
- /* ngx_null_string, */ /* "424 Failed Dependency" */
-
-#define NGX_HTTP_LAST_4XX 422
+#define NGX_HTTP_LAST_4XX 430
#define NGX_HTTP_OFF_5XX (NGX_HTTP_LAST_4XX - 400 + NGX_HTTP_OFF_4XX)

ngx_string("500 Internal Server Error"),
diff -r 8b7fd958c59f -r 9a63d6e990d2 src/http/ngx_http_request.h
--- a/src/http/ngx_http_request.h
+++ b/src/http/ngx_http_request.h
@@ -98,6 +98,7 @@
#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


/* Our own HTTP codes */
diff -r 8b7fd958c59f -r 9a63d6e990d2 src/http/ngx_http_special_response.c
--- a/src/http/ngx_http_special_response.c
+++ b/src/http/ngx_http_special_response.c
@@ -225,6 +225,14 @@ static char ngx_http_error_421_page[] =
;


+static char ngx_http_error_429_page[] =
+"<html>" CRLF
+"<head><title>429 Too Many Requests</title></head>" CRLF
+"<body bgcolor=\"white\">" CRLF
+"<center><h1>429 Too Many Requests</h1></center>" CRLF
+;
+
+
static char ngx_http_error_494_page[] =
"<html>" CRLF
"<head><title>400 Request Header Or Cookie Too Large</title></head>"
@@ -354,8 +362,16 @@ static ngx_str_t ngx_http_error_pages[]
ngx_null_string, /* 419 */
ngx_null_string, /* 420 */
ngx_string(ngx_http_error_421_page),
+ ngx_null_string, /* 422 */
+ ngx_null_string, /* 423 */
+ ngx_null_string, /* 424 */
+ ngx_null_string, /* 425 */
+ ngx_null_string, /* 426 */
+ ngx_null_string, /* 427 */
+ ngx_null_string, /* 428 */
+ ngx_string(ngx_http_error_429_page),

-#define NGX_HTTP_LAST_4XX 422
+#define NGX_HTTP_LAST_4XX 430
#define NGX_HTTP_OFF_5XX (NGX_HTTP_LAST_4XX - 400 + NGX_HTTP_OFF_4XX)

ngx_string(ngx_http_error_494_page), /* 494, request header too large */
_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH 1 of 2] HTTP: add support for "429 Too Many Requests" response (RFC6585)

Piotr Sikora 990 October 19, 2016 03:54AM

[PATCH 2 of 2] HTTP: change default response code when rate-limiting requests

Piotr Sikora 303 October 19, 2016 03:54AM

Re: [PATCH 1 of 2] HTTP: add support for "429 Too Many Requests" response (RFC6585)

Piotr Sikora via nginx-devel 287 November 29, 2016 08:10PM

Re: [PATCH 1 of 2] HTTP: add support for "429 Too Many Requests" response (RFC6585)

Piotr Sikora via nginx-devel 381 January 20, 2017 08:04PM

Re: [PATCH 1 of 2] HTTP: add support for "429 Too Many Requests" response (RFC6585)

Piotr Sikora via nginx-devel 231 February 22, 2017 10:40PM

Re: [PATCH 1 of 2] HTTP: add support for "429 Too Many Requests" response (RFC6585)

Maxim Dounin 237 February 25, 2017 06:46PM

[PATCH 1 of 3] HTTP: add support for "429 Too Many Requests" response (RFC6585)

Piotr Sikora via nginx-devel 586 February 28, 2017 06:42PM

[PATCH 2 of 3] Upstream: allow recovery from "429 Too Many Requests" response

Piotr Sikora via nginx-devel 288 February 28, 2017 06:42PM

Re: [PATCH 2 of 3] Upstream: allow recovery from "429 Too Many Requests" response

Maxim Dounin 231 March 01, 2017 10:34AM

Re: [PATCH 2 of 3] Upstream: allow recovery from "429 Too Many Requests" response

Piotr Sikora via nginx-devel 226 March 01, 2017 03:18PM

Re: [PATCH 2 of 3] Upstream: allow recovery from "429 Too Many Requests" response

Maxim Dounin 242 March 01, 2017 07:00PM

Re: [PATCH 2 of 3] Upstream: allow recovery from "429 Too Many Requests" response

Piotr Sikora via nginx-devel 240 March 24, 2017 06:50AM

[PATCH 3 of 3] Limit req: change default response code when rate-limiting

Piotr Sikora via nginx-devel 219 February 28, 2017 06:42PM

Re: [PATCH 3 of 3] Limit req: change default response code when rate-limiting

Maxim Dounin 227 March 01, 2017 10:40AM

Re: [PATCH 3 of 3] Limit req: change default response code when rate-limiting

Piotr Sikora via nginx-devel 217 March 01, 2017 03:22PM

Re: [PATCH 3 of 3] Limit req: change default response code when rate-limiting

Maxim Dounin 252 March 01, 2017 07:18PM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 228
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready