Mercurial > hg > nginx
comparison src/http/ngx_http_request.c @ 8679:e1eb7f4ca9f1 quic
HTTP/3: refactored request parser.
The change reduces diff to the default branch for
src/http/ngx_http_request.c and src/http/ngx_http_parse.c.
author | Roman Arutyunyan <arut@nginx.com> |
---|---|
date | Fri, 22 Jan 2021 16:34:06 +0300 |
parents | f61d347158d0 |
children | 6422455c92b4 |
comparison
equal
deleted
inserted
replaced
8678:3443ee341cc1 | 8679:e1eb7f4ca9f1 |
---|---|
29 static ngx_int_t ngx_http_process_connection(ngx_http_request_t *r, | 29 static ngx_int_t ngx_http_process_connection(ngx_http_request_t *r, |
30 ngx_table_elt_t *h, ngx_uint_t offset); | 30 ngx_table_elt_t *h, ngx_uint_t offset); |
31 static ngx_int_t ngx_http_process_user_agent(ngx_http_request_t *r, | 31 static ngx_int_t ngx_http_process_user_agent(ngx_http_request_t *r, |
32 ngx_table_elt_t *h, ngx_uint_t offset); | 32 ngx_table_elt_t *h, ngx_uint_t offset); |
33 | 33 |
34 static ngx_int_t ngx_http_validate_host(ngx_str_t *host, ngx_pool_t *pool, | |
35 ngx_uint_t alloc); | |
36 static ngx_int_t ngx_http_set_virtual_server(ngx_http_request_t *r, | |
37 ngx_str_t *host); | |
38 static ngx_int_t ngx_http_find_virtual_server(ngx_connection_t *c, | 34 static ngx_int_t ngx_http_find_virtual_server(ngx_connection_t *c, |
39 ngx_http_virtual_names_t *virtual_names, ngx_str_t *host, | 35 ngx_http_virtual_names_t *virtual_names, ngx_str_t *host, |
40 ngx_http_request_t *r, ngx_http_core_srv_conf_t **cscfp); | 36 ngx_http_request_t *r, ngx_http_core_srv_conf_t **cscfp); |
41 | 37 |
42 static void ngx_http_request_handler(ngx_event_t *ev); | 38 static void ngx_http_request_handler(ngx_event_t *ev); |
50 static void ngx_http_set_keepalive(ngx_http_request_t *r); | 46 static void ngx_http_set_keepalive(ngx_http_request_t *r); |
51 static void ngx_http_keepalive_handler(ngx_event_t *ev); | 47 static void ngx_http_keepalive_handler(ngx_event_t *ev); |
52 static void ngx_http_set_lingering_close(ngx_connection_t *c); | 48 static void ngx_http_set_lingering_close(ngx_connection_t *c); |
53 static void ngx_http_lingering_close_handler(ngx_event_t *ev); | 49 static void ngx_http_lingering_close_handler(ngx_event_t *ev); |
54 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r); | 50 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r); |
55 static void ngx_http_close_request(ngx_http_request_t *r, ngx_int_t error); | |
56 static void ngx_http_log_request(ngx_http_request_t *r); | 51 static void ngx_http_log_request(ngx_http_request_t *r); |
57 | 52 |
58 static u_char *ngx_http_log_error_handler(ngx_http_request_t *r, | 53 static u_char *ngx_http_log_error_handler(ngx_http_request_t *r, |
59 ngx_http_request_t *sr, u_char *buf, size_t len); | 54 ngx_http_request_t *sr, u_char *buf, size_t len); |
60 | 55 |
301 | 296 |
302 /* the default server configuration for the address:port */ | 297 /* the default server configuration for the address:port */ |
303 hc->conf_ctx = hc->addr_conf->default_server->ctx; | 298 hc->conf_ctx = hc->addr_conf->default_server->ctx; |
304 | 299 |
305 #if (NGX_HTTP_QUIC) | 300 #if (NGX_HTTP_QUIC) |
306 | |
307 if (hc->addr_conf->quic) { | 301 if (hc->addr_conf->quic) { |
308 ngx_quic_conf_t *qcf; | 302 if (ngx_http_quic_init(c) == NGX_DONE) { |
309 ngx_http_connection_t *phc; | |
310 ngx_http_core_loc_conf_t *clcf; | |
311 | |
312 hc->ssl = 1; | |
313 | |
314 #if (NGX_HTTP_V3) | |
315 | |
316 if (hc->addr_conf->http3) { | |
317 ngx_int_t rc; | |
318 | |
319 rc = ngx_http_v3_init_connection(c); | |
320 | |
321 if (rc == NGX_ERROR) { | |
322 ngx_http_close_connection(c); | |
323 return; | |
324 } | |
325 | |
326 if (rc == NGX_DONE) { | |
327 return; | |
328 } | |
329 } | |
330 | |
331 #endif | |
332 | |
333 if (c->quic == NULL) { | |
334 c->log->connection = c->number; | |
335 | |
336 qcf = ngx_http_get_module_srv_conf(hc->conf_ctx, | |
337 ngx_http_quic_module); | |
338 ngx_quic_run(c, qcf); | |
339 return; | 303 return; |
340 } | 304 } |
341 | 305 } |
342 phc = c->quic->parent->data; | |
343 | |
344 if (phc->ssl_servername) { | |
345 hc->ssl_servername = phc->ssl_servername; | |
346 hc->conf_ctx = phc->conf_ctx; | |
347 | |
348 clcf = ngx_http_get_module_loc_conf(hc->conf_ctx, | |
349 ngx_http_core_module); | |
350 ngx_set_connection_log(c, clcf->error_log); | |
351 } | |
352 } | |
353 | |
354 #endif | 306 #endif |
355 | 307 |
356 ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t)); | 308 ctx = ngx_palloc(c->pool, sizeof(ngx_http_log_ctx_t)); |
357 if (ctx == NULL) { | 309 if (ctx == NULL) { |
358 ngx_http_close_connection(c); | 310 ngx_http_close_connection(c); |
375 c->write->handler = ngx_http_empty_handler; | 327 c->write->handler = ngx_http_empty_handler; |
376 | 328 |
377 #if (NGX_HTTP_V2) | 329 #if (NGX_HTTP_V2) |
378 if (hc->addr_conf->http2) { | 330 if (hc->addr_conf->http2) { |
379 rev->handler = ngx_http_v2_init; | 331 rev->handler = ngx_http_v2_init; |
332 } | |
333 #endif | |
334 | |
335 #if (NGX_HTTP_V3) | |
336 if (hc->addr_conf->http3) { | |
337 ngx_http_v3_init(c); | |
338 return; | |
380 } | 339 } |
381 #endif | 340 #endif |
382 | 341 |
383 #if (NGX_HTTP_SSL) | 342 #if (NGX_HTTP_SSL) |
384 { | 343 { |
666 r->start_sec = tp->sec; | 625 r->start_sec = tp->sec; |
667 r->start_msec = tp->msec; | 626 r->start_msec = tp->msec; |
668 | 627 |
669 r->method = NGX_HTTP_UNKNOWN; | 628 r->method = NGX_HTTP_UNKNOWN; |
670 r->http_version = NGX_HTTP_VERSION_10; | 629 r->http_version = NGX_HTTP_VERSION_10; |
671 | |
672 #if (NGX_HTTP_V3) | |
673 if (hc->addr_conf->http3) { | |
674 r->http_version = NGX_HTTP_VERSION_30; | |
675 } | |
676 #endif | |
677 | 630 |
678 r->headers_in.content_length_n = -1; | 631 r->headers_in.content_length_n = -1; |
679 r->headers_in.keep_alive_n = -1; | 632 r->headers_in.keep_alive_n = -1; |
680 r->headers_out.content_length_n = -1; | 633 r->headers_out.content_length_n = -1; |
681 r->headers_out.last_modified_time = -1; | 634 r->headers_out.last_modified_time = -1; |
1138 if (n == NGX_AGAIN || n == NGX_ERROR) { | 1091 if (n == NGX_AGAIN || n == NGX_ERROR) { |
1139 break; | 1092 break; |
1140 } | 1093 } |
1141 } | 1094 } |
1142 | 1095 |
1143 switch (r->http_version) { | 1096 rc = ngx_http_parse_request_line(r, r->header_in); |
1144 #if (NGX_HTTP_V3) | |
1145 case NGX_HTTP_VERSION_30: | |
1146 rc = ngx_http_v3_parse_request(r, r->header_in); | |
1147 break; | |
1148 #endif | |
1149 | |
1150 default: /* HTTP/1.x */ | |
1151 rc = ngx_http_parse_request_line(r, r->header_in); | |
1152 } | |
1153 | 1097 |
1154 if (rc == NGX_OK) { | 1098 if (rc == NGX_OK) { |
1155 | 1099 |
1156 /* the request line has been parsed successfully */ | 1100 /* the request line has been parsed successfully */ |
1157 | 1101 |
1158 r->request_line.len = r->request_end - r->request_start; | 1102 r->request_line.len = r->request_end - r->request_start; |
1159 r->request_line.data = r->request_start; | 1103 r->request_line.data = r->request_start; |
1160 r->request_length = r->header_in->pos - r->parse_start; | 1104 r->request_length = r->header_in->pos - r->request_start; |
1161 | 1105 |
1162 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | 1106 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
1163 "http request line: \"%V\"", &r->request_line); | 1107 "http request line: \"%V\"", &r->request_line); |
1164 | 1108 |
1165 r->method_name.len = r->method_end - r->request_start + 1; | 1109 r->method_name.len = r->method_end - r->request_start + 1; |
1232 ngx_http_process_request_headers(rev); | 1176 ngx_http_process_request_headers(rev); |
1233 | 1177 |
1234 break; | 1178 break; |
1235 } | 1179 } |
1236 | 1180 |
1237 if (rc == NGX_BUSY) { | |
1238 if (ngx_handle_read_event(rev, 0) != NGX_OK) { | |
1239 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | |
1240 return; | |
1241 } | |
1242 | |
1243 break; | |
1244 } | |
1245 | |
1246 if (rc != NGX_AGAIN) { | 1181 if (rc != NGX_AGAIN) { |
1247 | 1182 |
1248 /* there was error while a request line parsing */ | 1183 /* there was error while a request line parsing */ |
1249 | 1184 |
1250 ngx_log_error(NGX_LOG_INFO, c->log, 0, | 1185 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
1270 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 1205 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1271 break; | 1206 break; |
1272 } | 1207 } |
1273 | 1208 |
1274 if (rv == NGX_DECLINED) { | 1209 if (rv == NGX_DECLINED) { |
1275 r->request_line.len = r->header_in->end - r->parse_start; | 1210 r->request_line.len = r->header_in->end - r->request_start; |
1276 r->request_line.data = r->parse_start; | 1211 r->request_line.data = r->request_start; |
1277 | 1212 |
1278 ngx_log_error(NGX_LOG_INFO, c->log, 0, | 1213 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
1279 "client sent too long URI"); | 1214 "client sent too long URI"); |
1280 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_URI_TOO_LARGE); | 1215 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_URI_TOO_LARGE); |
1281 break; | 1216 break; |
1435 return; | 1370 return; |
1436 } | 1371 } |
1437 | 1372 |
1438 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | 1373 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); |
1439 | 1374 |
1440 rc = NGX_OK; | 1375 rc = NGX_AGAIN; |
1441 | 1376 |
1442 for ( ;; ) { | 1377 for ( ;; ) { |
1443 | 1378 |
1444 if (rc == NGX_AGAIN) { | 1379 if (rc == NGX_AGAIN) { |
1445 | 1380 |
1451 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 1386 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1452 break; | 1387 break; |
1453 } | 1388 } |
1454 | 1389 |
1455 if (rv == NGX_DECLINED) { | 1390 if (rv == NGX_DECLINED) { |
1456 p = r->parse_start; | 1391 p = r->header_name_start; |
1457 | 1392 |
1458 r->lingering_close = 1; | 1393 r->lingering_close = 1; |
1459 | 1394 |
1460 if (p == NULL) { | 1395 if (p == NULL) { |
1461 ngx_log_error(NGX_LOG_INFO, c->log, 0, | 1396 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
1471 len = NGX_MAX_ERROR_STR - 300; | 1406 len = NGX_MAX_ERROR_STR - 300; |
1472 } | 1407 } |
1473 | 1408 |
1474 ngx_log_error(NGX_LOG_INFO, c->log, 0, | 1409 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
1475 "client sent too long header line: \"%*s...\"", | 1410 "client sent too long header line: \"%*s...\"", |
1476 len, r->parse_start); | 1411 len, r->header_name_start); |
1477 | 1412 |
1478 ngx_http_finalize_request(r, | 1413 ngx_http_finalize_request(r, |
1479 NGX_HTTP_REQUEST_HEADER_TOO_LARGE); | 1414 NGX_HTTP_REQUEST_HEADER_TOO_LARGE); |
1480 break; | 1415 break; |
1481 } | 1416 } |
1489 } | 1424 } |
1490 | 1425 |
1491 /* the host header could change the server configuration context */ | 1426 /* the host header could change the server configuration context */ |
1492 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | 1427 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
1493 | 1428 |
1494 switch (r->http_version) { | 1429 rc = ngx_http_parse_header_line(r, r->header_in, |
1495 #if (NGX_HTTP_V3) | 1430 cscf->underscores_in_headers); |
1496 case NGX_HTTP_VERSION_30: | |
1497 rc = ngx_http_v3_parse_header(r, r->header_in, | |
1498 cscf->underscores_in_headers); | |
1499 break; | |
1500 #endif | |
1501 | |
1502 default: /* HTTP/1.x */ | |
1503 rc = ngx_http_parse_header_line(r, r->header_in, | |
1504 cscf->underscores_in_headers); | |
1505 } | |
1506 | 1431 |
1507 if (rc == NGX_OK) { | 1432 if (rc == NGX_OK) { |
1508 | 1433 |
1509 r->request_length += r->header_in->pos - r->parse_start; | 1434 r->request_length += r->header_in->pos - r->header_name_start; |
1510 | 1435 |
1511 if (r->invalid_header && cscf->ignore_invalid_headers) { | 1436 if (r->invalid_header && cscf->ignore_invalid_headers) { |
1512 | 1437 |
1513 /* there was error while a header line parsing */ | 1438 /* there was error while a header line parsing */ |
1514 | 1439 |
1515 ngx_log_error(NGX_LOG_INFO, c->log, 0, | 1440 ngx_log_error(NGX_LOG_INFO, c->log, 0, |
1516 "client sent invalid header line: \"%*s: %*s\"", | 1441 "client sent invalid header line: \"%*s\"", |
1517 r->header_name_end - r->header_name_start, | 1442 r->header_end - r->header_name_start, |
1518 r->header_name_start, | 1443 r->header_name_start); |
1519 r->header_end - r->header_start, r->header_start); | |
1520 continue; | 1444 continue; |
1521 } | 1445 } |
1522 | 1446 |
1523 /* a header line has been parsed successfully */ | 1447 /* a header line has been parsed successfully */ |
1524 | 1448 |
1530 | 1454 |
1531 h->hash = r->header_hash; | 1455 h->hash = r->header_hash; |
1532 | 1456 |
1533 h->key.len = r->header_name_end - r->header_name_start; | 1457 h->key.len = r->header_name_end - r->header_name_start; |
1534 h->key.data = r->header_name_start; | 1458 h->key.data = r->header_name_start; |
1535 | 1459 h->key.data[h->key.len] = '\0'; |
1536 if (h->key.data[h->key.len]) { | |
1537 h->key.data[h->key.len] = '\0'; | |
1538 } | |
1539 | 1460 |
1540 h->value.len = r->header_end - r->header_start; | 1461 h->value.len = r->header_end - r->header_start; |
1541 h->value.data = r->header_start; | 1462 h->value.data = r->header_start; |
1542 | 1463 h->value.data[h->value.len] = '\0'; |
1543 if (h->value.data[h->value.len]) { | |
1544 h->value.data[h->value.len] = '\0'; | |
1545 } | |
1546 | 1464 |
1547 h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); | 1465 h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); |
1548 if (h->lowcase_key == NULL) { | 1466 if (h->lowcase_key == NULL) { |
1549 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); | 1467 ngx_http_close_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); |
1550 break; | 1468 break; |
1576 /* a whole header has been parsed successfully */ | 1494 /* a whole header has been parsed successfully */ |
1577 | 1495 |
1578 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 1496 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
1579 "http header done"); | 1497 "http header done"); |
1580 | 1498 |
1581 r->request_length += r->header_in->pos - r->parse_start; | 1499 r->request_length += r->header_in->pos - r->header_name_start; |
1582 | 1500 |
1583 r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE; | 1501 r->http_state = NGX_HTTP_PROCESS_REQUEST_STATE; |
1584 | 1502 |
1585 rc = ngx_http_process_request_header(r); | 1503 rc = ngx_http_process_request_header(r); |
1586 | 1504 |
1691 r->header_in->last = r->header_in->start; | 1609 r->header_in->last = r->header_in->start; |
1692 | 1610 |
1693 return NGX_OK; | 1611 return NGX_OK; |
1694 } | 1612 } |
1695 | 1613 |
1696 old = r->parse_start; | 1614 old = request_line ? r->request_start : r->header_name_start; |
1697 | 1615 |
1698 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | 1616 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
1699 | 1617 |
1700 if (r->state != 0 | 1618 if (r->state != 0 |
1701 && (size_t) (r->header_in->pos - old) | 1619 && (size_t) (r->header_in->pos - old) |
1769 ngx_memcpy(new, old, r->header_in->pos - old); | 1687 ngx_memcpy(new, old, r->header_in->pos - old); |
1770 | 1688 |
1771 b->pos = new + (r->header_in->pos - old); | 1689 b->pos = new + (r->header_in->pos - old); |
1772 b->last = new + (r->header_in->pos - old); | 1690 b->last = new + (r->header_in->pos - old); |
1773 | 1691 |
1774 r->parse_start = new; | |
1775 | |
1776 r->header_in = b; | |
1777 | |
1778 if (r->http_version > NGX_HTTP_VERSION_11) { | |
1779 return NGX_OK; | |
1780 } | |
1781 | |
1782 if (request_line) { | 1692 if (request_line) { |
1783 r->request_start = new; | 1693 r->request_start = new; |
1784 | 1694 |
1785 if (r->request_end) { | 1695 if (r->request_end) { |
1786 r->request_end = new + (r->request_end - old); | 1696 r->request_end = new + (r->request_end - old); |
1824 r->header_name_start = new; | 1734 r->header_name_start = new; |
1825 r->header_name_end = new + (r->header_name_end - old); | 1735 r->header_name_end = new + (r->header_name_end - old); |
1826 r->header_start = new + (r->header_start - old); | 1736 r->header_start = new + (r->header_start - old); |
1827 r->header_end = new + (r->header_end - old); | 1737 r->header_end = new + (r->header_end - old); |
1828 } | 1738 } |
1739 | |
1740 r->header_in = b; | |
1829 | 1741 |
1830 return NGX_OK; | 1742 return NGX_OK; |
1831 } | 1743 } |
1832 | 1744 |
1833 | 1745 |
2045 == NGX_ERROR) | 1957 == NGX_ERROR) |
2046 { | 1958 { |
2047 return NGX_ERROR; | 1959 return NGX_ERROR; |
2048 } | 1960 } |
2049 | 1961 |
2050 if (r->headers_in.host == NULL && r->http_version == NGX_HTTP_VERSION_11) { | 1962 if (r->headers_in.host == NULL && r->http_version > NGX_HTTP_VERSION_10) { |
2051 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | 1963 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, |
2052 "client sent HTTP/1.1 request without \"Host\" header"); | 1964 "client sent HTTP/1.1 request without \"Host\" header"); |
2053 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | 1965 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); |
2054 return NGX_ERROR; | 1966 return NGX_ERROR; |
2055 } | |
2056 | |
2057 if (r->headers_in.host == NULL && r->http_version == NGX_HTTP_VERSION_20) { | |
2058 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
2059 "client sent HTTP/2 request without " | |
2060 "\":authority\" or \"Host\" header"); | |
2061 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
2062 return NGX_ERROR; | |
2063 } | |
2064 | |
2065 if (r->http_version == NGX_HTTP_VERSION_30) { | |
2066 if (r->headers_in.server.len == 0) { | |
2067 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
2068 "client sent HTTP/3 request without " | |
2069 "\":authority\" or \"Host\" header"); | |
2070 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
2071 return NGX_ERROR; | |
2072 } | |
2073 | |
2074 if (r->headers_in.host) { | |
2075 if (r->headers_in.host->value.len != r->headers_in.server.len | |
2076 || ngx_memcmp(r->headers_in.host->value.data, | |
2077 r->headers_in.server.data, | |
2078 r->headers_in.server.len) | |
2079 != 0) | |
2080 { | |
2081 ngx_log_error(NGX_LOG_INFO, r->connection->log, 0, | |
2082 "client sent HTTP/3 request with different " | |
2083 "values of \":authority\" and \"Host\" headers"); | |
2084 ngx_http_finalize_request(r, NGX_HTTP_BAD_REQUEST); | |
2085 return NGX_ERROR; | |
2086 } | |
2087 } | |
2088 } | 1967 } |
2089 | 1968 |
2090 if (r->headers_in.content_length) { | 1969 if (r->headers_in.content_length) { |
2091 r->headers_in.content_length_n = | 1970 r->headers_in.content_length_n = |
2092 ngx_atoof(r->headers_in.content_length->value.data, | 1971 ngx_atoof(r->headers_in.content_length->value.data, |
2123 ngx_http_finalize_request(r, NGX_HTTP_NOT_IMPLEMENTED); | 2002 ngx_http_finalize_request(r, NGX_HTTP_NOT_IMPLEMENTED); |
2124 return NGX_ERROR; | 2003 return NGX_ERROR; |
2125 } | 2004 } |
2126 } | 2005 } |
2127 | 2006 |
2128 #if (NGX_HTTP_V3) | |
2129 if (r->http_version == NGX_HTTP_VERSION_30) { | |
2130 r->headers_in.chunked = 1; | |
2131 } | |
2132 #endif | |
2133 | |
2134 if (r->headers_in.connection_type == NGX_HTTP_CONNECTION_KEEP_ALIVE) { | 2007 if (r->headers_in.connection_type == NGX_HTTP_CONNECTION_KEEP_ALIVE) { |
2135 if (r->headers_in.keep_alive) { | 2008 if (r->headers_in.keep_alive) { |
2136 r->headers_in.keep_alive_n = | 2009 r->headers_in.keep_alive_n = |
2137 ngx_atotm(r->headers_in.keep_alive->value.data, | 2010 ngx_atotm(r->headers_in.keep_alive->value.data, |
2138 r->headers_in.keep_alive->value.len); | 2011 r->headers_in.keep_alive->value.len); |
2233 | 2106 |
2234 ngx_http_handler(r); | 2107 ngx_http_handler(r); |
2235 } | 2108 } |
2236 | 2109 |
2237 | 2110 |
2238 static ngx_int_t | 2111 ngx_int_t |
2239 ngx_http_validate_host(ngx_str_t *host, ngx_pool_t *pool, ngx_uint_t alloc) | 2112 ngx_http_validate_host(ngx_str_t *host, ngx_pool_t *pool, ngx_uint_t alloc) |
2240 { | 2113 { |
2241 u_char *h, ch; | 2114 u_char *h, ch; |
2242 size_t i, dot_pos, host_len; | 2115 size_t i, dot_pos, host_len; |
2243 | 2116 |
2324 | 2197 |
2325 return NGX_OK; | 2198 return NGX_OK; |
2326 } | 2199 } |
2327 | 2200 |
2328 | 2201 |
2329 static ngx_int_t | 2202 ngx_int_t |
2330 ngx_http_set_virtual_server(ngx_http_request_t *r, ngx_str_t *host) | 2203 ngx_http_set_virtual_server(ngx_http_request_t *r, ngx_str_t *host) |
2331 { | 2204 { |
2332 ngx_int_t rc; | 2205 ngx_int_t rc; |
2333 ngx_http_connection_t *hc; | 2206 ngx_http_connection_t *hc; |
2334 ngx_http_core_loc_conf_t *clcf; | 2207 ngx_http_core_loc_conf_t *clcf; |
3742 | 3615 |
3743 return NGX_OK; | 3616 return NGX_OK; |
3744 } | 3617 } |
3745 | 3618 |
3746 | 3619 |
3747 static void | 3620 void |
3748 ngx_http_close_request(ngx_http_request_t *r, ngx_int_t rc) | 3621 ngx_http_close_request(ngx_http_request_t *r, ngx_int_t rc) |
3749 { | 3622 { |
3750 ngx_connection_t *c; | 3623 ngx_connection_t *c; |
3751 | 3624 |
3752 r = r->main; | 3625 r = r->main; |
3963 | 3836 |
3964 p = ngx_snprintf(buf, len, ", server: %V", &cscf->server_name); | 3837 p = ngx_snprintf(buf, len, ", server: %V", &cscf->server_name); |
3965 len -= p - buf; | 3838 len -= p - buf; |
3966 buf = p; | 3839 buf = p; |
3967 | 3840 |
3968 if (r->request_line.data == NULL && r->parse_start) { | 3841 if (r->request_line.data == NULL && r->request_start) { |
3969 for (p = r->parse_start; p < r->header_in->last; p++) { | 3842 for (p = r->request_start; p < r->header_in->last; p++) { |
3970 if (*p == CR || *p == LF) { | 3843 if (*p == CR || *p == LF) { |
3971 break; | 3844 break; |
3972 } | 3845 } |
3973 } | 3846 } |
3974 | 3847 |
3975 r->request_line.len = p - r->parse_start; | 3848 r->request_line.len = p - r->request_start; |
3976 r->request_line.data = r->parse_start; | 3849 r->request_line.data = r->request_start; |
3977 } | 3850 } |
3978 | 3851 |
3979 if (r->request_line.len) { | 3852 if (r->request_line.len) { |
3980 p = ngx_snprintf(buf, len, ", request: \"%V\"", &r->request_line); | 3853 p = ngx_snprintf(buf, len, ", request: \"%V\"", &r->request_line); |
3981 len -= p - buf; | 3854 len -= p - buf; |