comparison src/http/ngx_http_request.c @ 412:b246022ef454 NGINX_0_7_18

nginx 0.7.18 *) Change: the "underscores_in_headers" directive; now nginx does not allows underscores in a client request header line names. *) Feature: the ngx_http_secure_link_module. *) Feature: the "real_ip_header" directive supports any header. *) Feature: the "log_subrequest" directive. *) Feature: the $realpath_root variable. *) Feature: the "http_502" and "http_504" parameters of the "proxy_next_upstream" directive. *) Bugfix: the "http_503" parameter of the "proxy_next_upstream" or "fastcgi_next_upstream" directives did not work. *) Bugfix: nginx might send a "Transfer-Encoding: chunked" heaer line for HEAD requests. *) Bugfix: now accept threshold depends on worker_connections.
author Igor Sysoev <http://sysoev.ru>
date Mon, 13 Oct 2008 00:00:00 +0400
parents a8e3f1441eec
children b4f69f2ef02c
comparison
equal deleted inserted replaced
411:b453a4324c60 412:b246022ef454
45 static void ngx_http_set_lingering_close(ngx_http_request_t *r); 45 static void ngx_http_set_lingering_close(ngx_http_request_t *r);
46 static void ngx_http_lingering_close_handler(ngx_event_t *ev); 46 static void ngx_http_lingering_close_handler(ngx_event_t *ev);
47 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r); 47 static ngx_int_t ngx_http_post_action(ngx_http_request_t *r);
48 static void ngx_http_close_request(ngx_http_request_t *r, ngx_int_t error); 48 static void ngx_http_close_request(ngx_http_request_t *r, ngx_int_t error);
49 static void ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error); 49 static void ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error);
50 static void ngx_http_log_request(ngx_http_request_t *r);
50 static void ngx_http_close_connection(ngx_connection_t *c); 51 static void ngx_http_close_connection(ngx_connection_t *c);
51 52
52 static u_char *ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len); 53 static u_char *ngx_http_log_error(ngx_log_t *log, u_char *buf, size_t len);
53 static u_char *ngx_http_log_error_handler(ngx_http_request_t *r, 54 static u_char *ngx_http_log_error_handler(ngx_http_request_t *r,
54 ngx_http_request_t *sr, u_char *buf, size_t len); 55 ngx_http_request_t *sr, u_char *buf, size_t len);
900 if (n == NGX_AGAIN || n == NGX_ERROR) { 901 if (n == NGX_AGAIN || n == NGX_ERROR) {
901 return; 902 return;
902 } 903 }
903 } 904 }
904 905
905 rc = ngx_http_parse_header_line(r, r->header_in); 906 rc = ngx_http_parse_header_line(r, r->header_in,
907 cscf->underscores_in_headers);
906 908
907 if (rc == NGX_OK) { 909 if (rc == NGX_OK) {
908 910
909 if (r->invalid_header && cscf->ignore_invalid_headers) { 911 if (r->invalid_header && cscf->ignore_invalid_headers) {
910 912
1756 1758
1757 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc)); 1759 ngx_http_finalize_request(r, ngx_http_special_response_handler(r, rc));
1758 return; 1760 return;
1759 } 1761 }
1760 1762
1763 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
1764
1765 if (r != r->main && !r->logged) {
1766
1767 if (clcf->log_subrequest) {
1768 ngx_http_log_request(r);
1769 }
1770
1771 r->logged = 1;
1772 }
1773
1761 if (r != r->main || rc == NGX_AGAIN) { 1774 if (r != r->main || rc == NGX_AGAIN) {
1762 if (ngx_http_set_write_handler(r) != NGX_OK) { 1775 if (ngx_http_set_write_handler(r) != NGX_OK) {
1763 return; 1776 return;
1764 } 1777 }
1765 } 1778 }
1853 1866
1854 if (c->read->eof) { 1867 if (c->read->eof) {
1855 ngx_http_close_request(r, 0); 1868 ngx_http_close_request(r, 0);
1856 return; 1869 return;
1857 } 1870 }
1858
1859 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
1860 1871
1861 if (!ngx_terminate 1872 if (!ngx_terminate
1862 && !ngx_exiting 1873 && !ngx_exiting
1863 && r->keepalive 1874 && r->keepalive
1864 && clcf->keepalive_timeout > 0) 1875 && clcf->keepalive_timeout > 0)
2601 2612
2602 2613
2603 static void 2614 static void
2604 ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error) 2615 ngx_http_request_done(ngx_http_request_t *r, ngx_int_t error)
2605 { 2616 {
2606 ngx_log_t *log; 2617 ngx_log_t *log;
2607 ngx_uint_t i, n; 2618 struct linger linger;
2608 struct linger linger; 2619 ngx_http_cleanup_t *cln;
2609 ngx_http_cleanup_t *cln; 2620 ngx_http_log_ctx_t *ctx;
2610 ngx_http_log_ctx_t *ctx; 2621 ngx_http_core_loc_conf_t *clcf;
2611 ngx_http_handler_pt *log_handler;
2612 ngx_http_core_loc_conf_t *clcf;
2613 ngx_http_core_main_conf_t *cmcf;
2614 2622
2615 log = r->connection->log; 2623 log = r->connection->log;
2616 2624
2617 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http close request"); 2625 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, log, 0, "http close request");
2618 2626
2643 r->headers_out.status = error; 2651 r->headers_out.status = error;
2644 } 2652 }
2645 2653
2646 log->action = "logging request"; 2654 log->action = "logging request";
2647 2655
2648 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); 2656 ngx_http_log_request(r);
2649
2650 log_handler = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.elts;
2651 n = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.nelts;
2652 for (i = 0; i < n; i++) {
2653 log_handler[i](r);
2654 }
2655 2657
2656 log->action = "closing request"; 2658 log->action = "closing request";
2657 2659
2658 if (r->connection->timedout) { 2660 if (r->connection->timedout) {
2659 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); 2661 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
2682 ngx_destroy_pool(r->pool); 2684 ngx_destroy_pool(r->pool);
2683 } 2685 }
2684 2686
2685 2687
2686 static void 2688 static void
2689 ngx_http_log_request(ngx_http_request_t *r)
2690 {
2691 ngx_uint_t i, n;
2692 ngx_http_handler_pt *log_handler;
2693 ngx_http_core_main_conf_t *cmcf;
2694
2695 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
2696
2697 log_handler = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.elts;
2698 n = cmcf->phases[NGX_HTTP_LOG_PHASE].handlers.nelts;
2699
2700 for (i = 0; i < n; i++) {
2701 log_handler[i](r);
2702 }
2703 }
2704
2705
2706 static void
2687 ngx_http_close_connection(ngx_connection_t *c) 2707 ngx_http_close_connection(ngx_connection_t *c)
2688 { 2708 {
2689 ngx_pool_t *pool; 2709 ngx_pool_t *pool;
2690 2710
2691 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, 2711 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0,