Klaus Demo nginx / dd888c4
nginx-0.0.11-2004-09-21-09:38:28 import Igor Sysoev 17 years ago
7 changed file(s) with 64 addition(s) and 30 deletion(s). Raw diff Collapse all Expand all
111111
112112 unsigned buffered:1;
113113 unsigned single_connection:1;
114 unsigned pipeline:1;
115114 unsigned unexpected_eof:1;
116115 unsigned timedout:1;
117116 signed tcp_nopush:2;
5656
5757 void ngx_http_init_connection(ngx_connection_t *c);
5858
59 ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r);
59 ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b);
6060 ngx_int_t ngx_http_parse_complex_uri(ngx_http_request_t *r);
6161 ngx_int_t ngx_http_parse_header_line(ngx_http_request_t *r, ngx_buf_t *b);
6262
130130 r->header_only = 1;
131131 }
132132
133 if (r->headers_out.last_modified_time != -1) {
134 if (r->headers_out.status != NGX_HTTP_OK
135 && r->headers_out.status != NGX_HTTP_NOT_MODIFIED
136 && r->headers_out.status != NGX_HTTP_PARTIAL_CONTENT)
137 {
138 r->headers_out.last_modified_time = -1;
139 r->headers_out.last_modified = NULL;
140 }
141 }
142
133143 /* 2 is for trailing "\r\n" and 2 is for "\r\n" in the end of header */
134144 len = sizeof("HTTP/1.x ") - 1 + 2 + 2;
135145
33 #include <ngx_http.h>
44
55
6 ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r)
6 ngx_int_t ngx_http_parse_request_line(ngx_http_request_t *r, ngx_buf_t *b)
77 {
88 u_char ch, *p, *m;
99 enum {
3333 } state;
3434
3535 state = r->state;
36 p = r->header_in->pos;
37
38 while (p < r->header_in->last && state < sw_done) {
36 p = b->pos;
37
38 while (p < b->last && state < sw_done) {
3939 ch = *p++;
4040
4141 /* gcc 2.95.2 and vc 6.0 compile this switch as an jump table */
415415 }
416416 }
417417
418 r->header_in->pos = p;
418 b->pos = p;
419419
420420 if (state == sw_done) {
421421 if (r->request_end == NULL) {
171171 ngx_http_request_t *r;
172172 ngx_http_in_port_t *in_port;
173173 ngx_http_in_addr_t *in_addr;
174 ngx_http_connection_t *hc;
174175 ngx_http_server_name_t *server_name;
175176 ngx_http_core_srv_conf_t *cscf;
176177 ngx_http_core_loc_conf_t *clcf;
192193 }
193194
194195 if (c->data) {
195 r = c->data;
196 hc = c->data;
197 r = hc->request;
198
196199 ngx_memzero(r, sizeof(ngx_http_request_t));
200
201 r->pipeline = hc->pipeline;
197202
198203 #if (NGX_STAT_STUB)
199204 (*ngx_stat_reading)++;
200205 #endif
201206
202207 } else {
203 if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) {
208 if (!(hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)))) {
204209
205210 #if (NGX_STAT_STUB)
206211 (*ngx_stat_reading)--;
210215 return;
211216 }
212217
213 c->data = r;
218 if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) {
219
220 #if (NGX_STAT_STUB)
221 (*ngx_stat_reading)--;
222 #endif
223
224 ngx_http_close_connection(c);
225 return;
226 }
227
228 hc->request = r;
214229 }
215230
216231 #if (NGX_STAT_STUB)
217232 r->stat_reading = 1;
218233 #endif
234
235 c->data = r;
236 r->http_connection = hc;
219237
220238 c->sent = 0;
221239 r->signature = NGX_HTTP_MODULE;
366384
367385 c->single_connection = 1;
368386 r->connection = c;
369 r->pipeline = c->pipeline;
370387 r->header_in = c->buffer;
371388
372389 r->file.fd = NGX_INVALID_FILE;
475492 return;
476493 }
477494
478 rc = ngx_http_parse_request_line(r);
495 rc = ngx_http_parse_request_line(r, r->header_in);
479496
480497 if (rc == NGX_OK) {
481498
482499 /* the request line has been parsed successfully */
483
484 #if 0
485 /* TODO: we need to handle proxy URIs */
486 if (r->unusual_uri) {
487 r->request_line.len = r->request_end - r->request_start;
488 r->request_line.data = r->request_start;
489 #if 0
490 r->request_line.data[r->request_line.len] = '\0';
491 #endif
492
493 ngx_http_client_error(r, NGX_HTTP_PARSE_INVALID_REQUEST,
494 NGX_HTTP_BAD_REQUEST);
495 return;
496 }
497 #endif
498500
499501 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
500502
15031505 ngx_buf_t *b;
15041506 ngx_event_t *rev, *wev;
15051507 ngx_connection_t *c;
1508 ngx_http_connection_t *hc;
15061509 ngx_http_log_ctx_t *ctx;
15071510 ngx_http_core_srv_conf_t *cscf;
15081511 ngx_http_core_loc_conf_t *clcf;
15141517
15151518 ctx = (ngx_http_log_ctx_t *) c->log->data;
15161519 ctx->action = "closing request";
1520
1521 hc = r->http_connection;
15171522 ngx_http_close_request(r, 0);
1523 c->data = hc;
15181524
15191525 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
15201526 ngx_add_timer(rev, clcf->keepalive_timeout);
15521558
15531559 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "pipelined request");
15541560
1555 c->pipeline = 1;
1561 hc->pipeline = 1;
15561562 ctx->action = "reading client pipelined request line";
15571563 ngx_http_init_request(rev);
15581564 return;
15591565 }
15601566
1561 c->pipeline = 0;
1567 hc->pipeline = 0;
15621568
15631569 b->pos = b->last = b->start;
15641570 rev->event_handler = ngx_http_keepalive_handler;
16471653 c->buffer->last += n;
16481654 rev->log->handler = ngx_http_log_error;
16491655 ctx->action = "reading client request line";
1656
1657 #if 0
1658 if (!(hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)) {
1659 ngx_http_close_connection(c);
1660 return;
1661 }
1662
1663 hc->request = r;
1664 c->data = r;
1665 #endif
16501666
16511667 ngx_http_init_request(rev);
16521668 }
216216 };
217217
218218
219 typedef struct {
220 ngx_http_request_t *request;
221 ngx_array_t large_buffers;
222 ngx_uint_t pipeline; /* unsigned pipeline:1; */
223 } ngx_http_connection_t;
224
225
219226 typedef ngx_int_t (*ngx_http_handler_pt)(ngx_http_request_t *r);
220227
221228 struct ngx_http_request_s {
275282 u_char *discarded_buffer;
276283 void **err_ctx;
277284 ngx_uint_t err_status;
285
286 ngx_http_connection_t *http_connection;
278287
279288 unsigned http_state:4;
280289
6262
6363 void ngx_debug_init()
6464 {
65 #if (NGX_DEBUG)
65 #if (NGX_DEBUG && !NGX_NO_DEBUG_MALLOC)
6666
6767 #if __FreeBSD_version >= 500014
6868 _malloc_options = "J";