Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 9275:199dc0d6b05b
Added max_headers directive.
The directive limits the number of request headers accepted from clients.
While the total amount of headers is believed to be sufficiently limited
by the existing buffer size limits (client_header_buffer_size and
large_client_header_buffers), the additional limit on the number of headers
might be beneficial to better protect backend servers.
Requested by Maksim Yevmenkin.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Fri, 24 May 2024 00:20:01 +0300 |
parents | f798ecafec05 |
children | 3c71158f5a34 |
comparison
equal
deleted
inserted
replaced
9274:46ecad404a29 | 9275:199dc0d6b05b |
---|---|
1463 r->header_name_start); | 1463 r->header_name_start); |
1464 continue; | 1464 continue; |
1465 } | 1465 } |
1466 | 1466 |
1467 /* a header line has been parsed successfully */ | 1467 /* a header line has been parsed successfully */ |
1468 | |
1469 if (r->headers_in.count++ >= cscf->max_headers) { | |
1470 r->lingering_close = 1; | |
1471 ngx_log_error(NGX_LOG_INFO, c->log, 0, | |
1472 "client sent too many header lines"); | |
1473 ngx_http_finalize_request(r, | |
1474 NGX_HTTP_REQUEST_HEADER_TOO_LARGE); | |
1475 break; | |
1476 } | |
1468 | 1477 |
1469 h = ngx_list_push(&r->headers_in.headers); | 1478 h = ngx_list_push(&r->headers_in.headers); |
1470 if (h == NULL) { | 1479 if (h == NULL) { |
1471 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 1480 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1472 break; | 1481 break; |