# HG changeset patch # User Igor Sysoev # Date 1095745108 0 # Node ID 11362a3e3911d36de83c0469f96b9f5a885e8548 # Parent 358bbd2561b506cbc6cc956912c7f75afa7730df nginx-0.0.11-2004-09-21-09:38:28 import diff --git a/src/core/ngx_connection.h b/src/core/ngx_connection.h --- a/src/core/ngx_connection.h +++ b/src/core/ngx_connection.h @@ -112,7 +112,6 @@ struct ngx_connection_s { unsigned buffered:1; unsigned single_connection:1; - unsigned pipeline:1; unsigned unexpected_eof:1; unsigned timedout:1; signed tcp_nopush:2; diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h --- a/src/http/ngx_http.h +++ b/src/http/ngx_http.h @@ -57,7 +57,7 @@ typedef struct { void ngx_http_init_connection(ngx_connection_t *c); -ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r); +ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b); ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r); ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b); diff --git a/src/http/ngx_http_header_filter.c b/src/http/ngx_http_header_filter.c --- a/src/http/ngx_http_header_filter.c +++ b/src/http/ngx_http_header_filter.c @@ -131,6 +131,16 @@ static ngx_int_t ngx_http_header_filter( r->header_only = 1; } + if (r->headers_out.last_modified_time != -1) { + if (r->headers_out.status != NGX_HTTP_OK + && r->headers_out.status != NGX_HTTP_NOT_MODIFIED + && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT) + { + r->headers_out.last_modified_time = -1; + r->headers_out.last_modified = NULL; + } + } + /* 2 is for trailing "\r\n" and 2 is for "\r\n" in the end of header */ len = sizeof("HTTP/1.x ") - 1 + 2 + 2; diff --git a/src/http/ngx_http_parse.c b/src/http/ngx_http_parse.c --- a/src/http/ngx_http_parse.c +++ b/src/http/ngx_http_parse.c @@ -4,7 +4,7 @@ #include -ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r) +ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b) { u_char ch, *p, *m; enum { @@ -34,9 +34,9 @@ ngx_int_t ngx_http_parse_request_line(ng } state; state = r->state; - p = r->header_in->pos; + p = b->pos; - while (p < r->header_in->last && state < sw_done) { + while (p < b->last && state < sw_done) { ch = *p++; /* gcc 2.95.2 and vc 6.0 compile this switch as an jump table */ @@ -416,7 +416,7 @@ ngx_int_t ngx_http_parse_request_line(ng } } - r->header_in->pos = p; + b->pos = p; if (state == sw_done) { if (r->request_end == NULL) { diff --git a/src/http/ngx_http_request.c b/src/http/ngx_http_request.c --- a/src/http/ngx_http_request.c +++ b/src/http/ngx_http_request.c @@ -172,6 +172,7 @@ static void ngx_http_init_request(ngx_ev ngx_http_request_t *r; ngx_http_in_port_t *in_port; ngx_http_in_addr_t *in_addr; + ngx_http_connection_t *hc; ngx_http_server_name_t *server_name; ngx_http_core_srv_conf_t *cscf; ngx_http_core_loc_conf_t *clcf; @@ -193,14 +194,28 @@ static void ngx_http_init_request(ngx_ev } if (c->data) { - r = c->data; + hc = c->data; + r = hc->request; + ngx_memzero(r, sizeof(ngx_http_request_t)); + r->pipeline = hc->pipeline; + #if (NGX_STAT_STUB) (*ngx_stat_reading)++; #endif } else { + if (!(hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)))) { + +#if (NGX_STAT_STUB) + (*ngx_stat_reading)--; +#endif + + ngx_http_close_connection(c); + return; + } + if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) { #if (NGX_STAT_STUB) @@ -211,13 +226,16 @@ static void ngx_http_init_request(ngx_ev return; } - c->data = r; + hc->request = r; } #if (NGX_STAT_STUB) r->stat_reading = 1; #endif + c->data = r; + r->http_connection = hc; + c->sent = 0; r->signature = NGX_HTTP_MODULE; @@ -367,7 +385,6 @@ static void ngx_http_init_request(ngx_ev c->single_connection = 1; r->connection = c; - r->pipeline = c->pipeline; r->header_in = c->buffer; r->file.fd = NGX_INVALID_FILE; @@ -476,27 +493,12 @@ static void ngx_http_process_request_lin return; } - rc = ngx_http_parse_request_line(r); + rc = ngx_http_parse_request_line(r, r->header_in); if (rc == NGX_OK) { /* the request line has been parsed successfully */ -#if 0 - /* TODO: we need to handle proxy URIs */ - if (r->unusual_uri) { - r->request_line.len = r->request_end - r->request_start; - r->request_line.data = r->request_start; -#if 0 - r->request_line.data[r->request_line.len] = '\0'; -#endif - - ngx_http_client_error(r, NGX_HTTP_PARSE_INVALID_REQUEST, - NGX_HTTP_BAD_REQUEST); - return; - } -#endif - cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); if (r->http_version >= NGX_HTTP_VERSION_10 @@ -1504,6 +1506,7 @@ static void ngx_http_set_keepalive(ngx_h ngx_buf_t *b; ngx_event_t *rev, *wev; ngx_connection_t *c; + ngx_http_connection_t *hc; ngx_http_log_ctx_t *ctx; ngx_http_core_srv_conf_t *cscf; ngx_http_core_loc_conf_t *clcf; @@ -1515,7 +1518,10 @@ static void ngx_http_set_keepalive(ngx_h ctx = (ngx_http_log_ctx_t *) c->log->data; ctx->action = "closing request"; + + hc = r->http_connection; ngx_http_close_request(r, 0); + c->data = hc; clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); ngx_add_timer(rev, clcf->keepalive_timeout); @@ -1553,13 +1559,13 @@ static void ngx_http_set_keepalive(ngx_h ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "pipelined request"); - c->pipeline = 1; + hc->pipeline = 1; ctx->action = "reading client pipelined request line"; ngx_http_init_request(rev); return; } - c->pipeline = 0; + hc->pipeline = 0; b->pos = b->last = b->start; rev->event_handler = ngx_http_keepalive_handler; @@ -1649,6 +1655,16 @@ static void ngx_http_keepalive_handler(n rev->log->handler = ngx_http_log_error; ctx->action = "reading client request line"; +#if 0 + if (!(hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)) { + ngx_http_close_connection(c); + return; + } + + hc->request = r; + c->data = r; +#endif + ngx_http_init_request(rev); } diff --git a/src/http/ngx_http_request.h b/src/http/ngx_http_request.h --- a/src/http/ngx_http_request.h +++ b/src/http/ngx_http_request.h @@ -217,6 +217,13 @@ struct ngx_http_cleanup_s { }; +typedef struct { + ngx_http_request_t *request; + ngx_array_t large_buffers; + ngx_uint_t pipeline; /* unsigned pipeline:1; */ +} ngx_http_connection_t; + + typedef ngx_int_t (*ngx_http_handler_pt)(ngx_http_request_t *r); struct ngx_http_request_s { @@ -277,6 +284,8 @@ struct ngx_http_request_s { void **err_ctx; ngx_uint_t err_status; + ngx_http_connection_t *http_connection; + unsigned http_state:4; #if 0 diff --git a/src/os/unix/ngx_freebsd_init.c b/src/os/unix/ngx_freebsd_init.c --- a/src/os/unix/ngx_freebsd_init.c +++ b/src/os/unix/ngx_freebsd_init.c @@ -63,7 +63,7 @@ sysctl_t sysctls[] = { void ngx_debug_init() { -#if (NGX_DEBUG) +#if (NGX_DEBUG && !NGX_NO_DEBUG_MALLOC) #if __FreeBSD_version >= 500014 _malloc_options = "J";