Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nginx/nginx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/http
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-09-21 09:38:28 +0400
committerIgor Sysoev <igor@sysoev.ru>2004-09-21 09:38:28 +0400
commitdd888c4caadfbd94c595e6e39bdb361de82dda9f (patch)
tree70b87e5dded501cf3c7449e4baa98f69a6fd0607 /src/http
parente5dabbf077412b8a7a3caf6501e3a410256fcf72 (diff)
nginx-0.0.11-2004-09-21-09:38:28 import
Diffstat (limited to 'src/http')
-rw-r--r--src/http/ngx_http.h2
-rw-r--r--src/http/ngx_http_header_filter.c10
-rw-r--r--src/http/ngx_http_parse.c8
-rw-r--r--src/http/ngx_http_request.c58
-rw-r--r--src/http/ngx_http_request.h9
5 files changed, 61 insertions, 26 deletions
diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h
index b1f8a7d1b..23a95ed5a 100644
--- 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
index 74e36baec..20389426c 100644
--- 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(ngx_http_request_t *r)
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
index dd2d3749a..b1fb6c672 100644
--- a/src/http/ngx_http_parse.c
+++ b/src/http/ngx_http_parse.c
@@ -4,7 +4,7 @@
#include <ngx_http.h>
-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(ngx_http_request_t *r)
} 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(ngx_http_request_t *r)
}
}
- 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
index bc2102181..bb1cc7d76 100644
--- 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_event_t *rev)
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_event_t *rev)
}
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_event_t *rev)
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_event_t *rev)
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_line(ngx_event_t *rev)
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_http_request_t *r)
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_http_request_t *r)
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_http_request_t *r)
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(ngx_event_t *rev)
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
index aafabbea3..4dd1e82ee 100644
--- 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