comparison src/http/v2/ngx_http_v2.c @ 7774:827202ca1269

HTTP/2: removed http2_max_field_size and http2_max_header_size. Instead, size of one large_client_header_buffers buffer and all large client header buffers are used.
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 11 Feb 2021 21:52:26 +0300
parents b64f553b1291
children 171682010da4
comparison
equal deleted inserted replaced
7773:b64f553b1291 7774:827202ca1269
1196 weight; 1196 weight;
1197 ngx_uint_t status; 1197 ngx_uint_t status;
1198 ngx_http_v2_node_t *node; 1198 ngx_http_v2_node_t *node;
1199 ngx_http_v2_stream_t *stream; 1199 ngx_http_v2_stream_t *stream;
1200 ngx_http_v2_srv_conf_t *h2scf; 1200 ngx_http_v2_srv_conf_t *h2scf;
1201 ngx_http_core_srv_conf_t *cscf;
1201 ngx_http_core_loc_conf_t *clcf; 1202 ngx_http_core_loc_conf_t *clcf;
1202 1203
1203 padded = h2c->state.flags & NGX_HTTP_V2_PADDED_FLAG; 1204 padded = h2c->state.flags & NGX_HTTP_V2_PADDED_FLAG;
1204 priority = h2c->state.flags & NGX_HTTP_V2_PRIORITY_FLAG; 1205 priority = h2c->state.flags & NGX_HTTP_V2_PRIORITY_FLAG;
1205 1206
1297 h2c->state.pool = ngx_create_pool(1024, h2c->connection->log); 1298 h2c->state.pool = ngx_create_pool(1024, h2c->connection->log);
1298 if (h2c->state.pool == NULL) { 1299 if (h2c->state.pool == NULL) {
1299 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR); 1300 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_INTERNAL_ERROR);
1300 } 1301 }
1301 1302
1303 cscf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
1304 ngx_http_core_module);
1305
1306 h2c->state.header_limit = cscf->large_client_header_buffers.size
1307 * cscf->large_client_header_buffers.num;
1308
1302 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, 1309 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
1303 ngx_http_v2_module); 1310 ngx_http_v2_module);
1304
1305 h2c->state.header_limit = h2scf->max_header_size;
1306 1311
1307 if (h2c->processing >= h2scf->concurrent_streams) { 1312 if (h2c->processing >= h2scf->concurrent_streams) {
1308 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, 1313 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
1309 "concurrent streams exceeded %ui", h2c->processing); 1314 "concurrent streams exceeded %ui", h2c->processing);
1310 1315
1483 1488
1484 static u_char * 1489 static u_char *
1485 ngx_http_v2_state_field_len(ngx_http_v2_connection_t *h2c, u_char *pos, 1490 ngx_http_v2_state_field_len(ngx_http_v2_connection_t *h2c, u_char *pos,
1486 u_char *end) 1491 u_char *end)
1487 { 1492 {
1488 size_t alloc; 1493 size_t alloc;
1489 ngx_int_t len; 1494 ngx_int_t len;
1490 ngx_uint_t huff; 1495 ngx_uint_t huff;
1491 ngx_http_v2_srv_conf_t *h2scf; 1496 ngx_http_core_srv_conf_t *cscf;
1492 1497
1493 if (!(h2c->state.flags & NGX_HTTP_V2_END_HEADERS_FLAG) 1498 if (!(h2c->state.flags & NGX_HTTP_V2_END_HEADERS_FLAG)
1494 && h2c->state.length < NGX_HTTP_V2_INT_OCTETS) 1499 && h2c->state.length < NGX_HTTP_V2_INT_OCTETS)
1495 { 1500 {
1496 return ngx_http_v2_handle_continuation(h2c, pos, end, 1501 return ngx_http_v2_handle_continuation(h2c, pos, end,
1533 1538
1534 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0, 1539 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, h2c->connection->log, 0,
1535 "http2 %s string, len:%i", 1540 "http2 %s string, len:%i",
1536 huff ? "encoded" : "raw", len); 1541 huff ? "encoded" : "raw", len);
1537 1542
1538 h2scf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx, 1543 cscf = ngx_http_get_module_srv_conf(h2c->http_connection->conf_ctx,
1539 ngx_http_v2_module); 1544 ngx_http_core_module);
1540 1545
1541 if ((size_t) len > h2scf->max_field_size) { 1546 if ((size_t) len > cscf->large_client_header_buffers.size) {
1542 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, 1547 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
1543 "client exceeded http2_max_field_size limit"); 1548 "client sent too large header field");
1544 1549
1545 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM); 1550 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM);
1546 } 1551 }
1547 1552
1548 h2c->state.field_rest = len; 1553 h2c->state.field_rest = len;
1753 1758
1754 len = header->name.len + header->value.len; 1759 len = header->name.len + header->value.len;
1755 1760
1756 if (len > h2c->state.header_limit) { 1761 if (len > h2c->state.header_limit) {
1757 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0, 1762 ngx_log_error(NGX_LOG_INFO, h2c->connection->log, 0,
1758 "client exceeded http2_max_header_size limit"); 1763 "client sent too large header");
1759 1764
1760 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM); 1765 return ngx_http_v2_connection_error(h2c, NGX_HTTP_V2_ENHANCE_YOUR_CALM);
1761 } 1766 }
1762 1767
1763 h2c->state.header_limit -= len; 1768 h2c->state.header_limit -= len;