diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c index 55e220a31..bd51e061f 100644 --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -978,10 +978,13 @@ ngx_http_process_request_headers(ngx_event_t *rev) if (rv == NGX_DECLINED) { p = r->header_name_start; + r->lingering_close = 1; + if (p == NULL) { ngx_log_error(NGX_LOG_INFO, c->log, 0, "client sent too large request"); - ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); + ngx_http_finalize_request(r, + NGX_HTTP_REQUEST_HEADER_TOO_LARGE); return; } @@ -995,7 +998,9 @@ ngx_http_process_request_headers(ngx_event_t *rev) ngx_log_error(NGX_LOG_INFO, c->log, 0, "client sent too long header line: \"%*s\"", len, r->header_name_start); - ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); + + ngx_http_finalize_request(r, + NGX_HTTP_REQUEST_HEADER_TOO_LARGE); return; } } diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h index b58c4d7d2..c20810ed5 100644 --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -95,7 +95,9 @@ /* The special code to close connection without any response */ #define NGX_HTTP_CLOSE 444 -#define NGX_HTTP_NGINX_CODES 495 +#define NGX_HTTP_NGINX_CODES 494 + +#define NGX_HTTP_REQUEST_HEADER_TOO_LARGE 494 #define NGX_HTTPS_CERT_ERROR 495 #define NGX_HTTPS_NO_CERT 496 diff --git a/src/http/ngx_http_special_response.c b/src/http/ngx_http_special_response.c index 487c65a2f..ed87fd068 100644 --- a/src/http/ngx_http_special_response.c +++ b/src/http/ngx_http_special_response.c @@ -201,6 +201,16 @@ static char ngx_http_error_416_page[] = ; +static char ngx_http_error_494_page[] = +"" CRLF +"