Mercurial > hg > nginx-quic
comparison src/http/ngx_http_request.c @ 432:11362a3e3911
nginx-0.0.11-2004-09-21-09:38:28 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 21 Sep 2004 05:38:28 +0000 |
parents | 1fa5daf7558e |
children | 5cdc4838d4e8 |
comparison
equal
deleted
inserted
replaced
431:358bbd2561b5 | 432:11362a3e3911 |
---|---|
170 struct sockaddr_in addr_in; | 170 struct sockaddr_in addr_in; |
171 ngx_connection_t *c; | 171 ngx_connection_t *c; |
172 ngx_http_request_t *r; | 172 ngx_http_request_t *r; |
173 ngx_http_in_port_t *in_port; | 173 ngx_http_in_port_t *in_port; |
174 ngx_http_in_addr_t *in_addr; | 174 ngx_http_in_addr_t *in_addr; |
175 ngx_http_connection_t *hc; | |
175 ngx_http_server_name_t *server_name; | 176 ngx_http_server_name_t *server_name; |
176 ngx_http_core_srv_conf_t *cscf; | 177 ngx_http_core_srv_conf_t *cscf; |
177 ngx_http_core_loc_conf_t *clcf; | 178 ngx_http_core_loc_conf_t *clcf; |
178 #if (NGX_HTTP_SSL) | 179 #if (NGX_HTTP_SSL) |
179 ngx_http_ssl_srv_conf_t *sscf; | 180 ngx_http_ssl_srv_conf_t *sscf; |
191 ngx_http_close_connection(c); | 192 ngx_http_close_connection(c); |
192 return; | 193 return; |
193 } | 194 } |
194 | 195 |
195 if (c->data) { | 196 if (c->data) { |
196 r = c->data; | 197 hc = c->data; |
198 r = hc->request; | |
199 | |
197 ngx_memzero(r, sizeof(ngx_http_request_t)); | 200 ngx_memzero(r, sizeof(ngx_http_request_t)); |
201 | |
202 r->pipeline = hc->pipeline; | |
198 | 203 |
199 #if (NGX_STAT_STUB) | 204 #if (NGX_STAT_STUB) |
200 (*ngx_stat_reading)++; | 205 (*ngx_stat_reading)++; |
201 #endif | 206 #endif |
202 | 207 |
203 } else { | 208 } else { |
204 if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) { | 209 if (!(hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)))) { |
205 | 210 |
206 #if (NGX_STAT_STUB) | 211 #if (NGX_STAT_STUB) |
207 (*ngx_stat_reading)--; | 212 (*ngx_stat_reading)--; |
208 #endif | 213 #endif |
209 | 214 |
210 ngx_http_close_connection(c); | 215 ngx_http_close_connection(c); |
211 return; | 216 return; |
212 } | 217 } |
213 | 218 |
214 c->data = r; | 219 if (!(r = ngx_pcalloc(c->pool, sizeof(ngx_http_request_t)))) { |
220 | |
221 #if (NGX_STAT_STUB) | |
222 (*ngx_stat_reading)--; | |
223 #endif | |
224 | |
225 ngx_http_close_connection(c); | |
226 return; | |
227 } | |
228 | |
229 hc->request = r; | |
215 } | 230 } |
216 | 231 |
217 #if (NGX_STAT_STUB) | 232 #if (NGX_STAT_STUB) |
218 r->stat_reading = 1; | 233 r->stat_reading = 1; |
219 #endif | 234 #endif |
235 | |
236 c->data = r; | |
237 r->http_connection = hc; | |
220 | 238 |
221 c->sent = 0; | 239 c->sent = 0; |
222 r->signature = NGX_HTTP_MODULE; | 240 r->signature = NGX_HTTP_MODULE; |
223 | 241 |
224 /* find the server configuration for the address:port */ | 242 /* find the server configuration for the address:port */ |
365 return; | 383 return; |
366 } | 384 } |
367 | 385 |
368 c->single_connection = 1; | 386 c->single_connection = 1; |
369 r->connection = c; | 387 r->connection = c; |
370 r->pipeline = c->pipeline; | |
371 r->header_in = c->buffer; | 388 r->header_in = c->buffer; |
372 | 389 |
373 r->file.fd = NGX_INVALID_FILE; | 390 r->file.fd = NGX_INVALID_FILE; |
374 | 391 |
375 r->headers_in.content_length_n = -1; | 392 r->headers_in.content_length_n = -1; |
474 | 491 |
475 if (n == NGX_AGAIN || n == NGX_ERROR) { | 492 if (n == NGX_AGAIN || n == NGX_ERROR) { |
476 return; | 493 return; |
477 } | 494 } |
478 | 495 |
479 rc = ngx_http_parse_request_line(r); | 496 rc = ngx_http_parse_request_line(r, r->header_in); |
480 | 497 |
481 if (rc == NGX_OK) { | 498 if (rc == NGX_OK) { |
482 | 499 |
483 /* the request line has been parsed successfully */ | 500 /* the request line has been parsed successfully */ |
484 | |
485 #if 0 | |
486 /* TODO: we need to handle proxy URIs */ | |
487 if (r->unusual_uri) { | |
488 r->request_line.len = r->request_end - r->request_start; | |
489 r->request_line.data = r->request_start; | |
490 #if 0 | |
491 r->request_line.data[r->request_line.len] = '\0'; | |
492 #endif | |
493 | |
494 ngx_http_client_error(r, NGX_HTTP_PARSE_INVALID_REQUEST, | |
495 NGX_HTTP_BAD_REQUEST); | |
496 return; | |
497 } | |
498 #endif | |
499 | 501 |
500 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | 502 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
501 | 503 |
502 if (r->http_version >= NGX_HTTP_VERSION_10 | 504 if (r->http_version >= NGX_HTTP_VERSION_10 |
503 && cscf->large_client_header == 0 | 505 && cscf->large_client_header == 0 |
1502 { | 1504 { |
1503 size_t len; | 1505 size_t len; |
1504 ngx_buf_t *b; | 1506 ngx_buf_t *b; |
1505 ngx_event_t *rev, *wev; | 1507 ngx_event_t *rev, *wev; |
1506 ngx_connection_t *c; | 1508 ngx_connection_t *c; |
1509 ngx_http_connection_t *hc; | |
1507 ngx_http_log_ctx_t *ctx; | 1510 ngx_http_log_ctx_t *ctx; |
1508 ngx_http_core_srv_conf_t *cscf; | 1511 ngx_http_core_srv_conf_t *cscf; |
1509 ngx_http_core_loc_conf_t *clcf; | 1512 ngx_http_core_loc_conf_t *clcf; |
1510 | 1513 |
1511 c = r->connection; | 1514 c = r->connection; |
1513 | 1516 |
1514 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "set http keepalive handler"); | 1517 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "set http keepalive handler"); |
1515 | 1518 |
1516 ctx = (ngx_http_log_ctx_t *) c->log->data; | 1519 ctx = (ngx_http_log_ctx_t *) c->log->data; |
1517 ctx->action = "closing request"; | 1520 ctx->action = "closing request"; |
1521 | |
1522 hc = r->http_connection; | |
1518 ngx_http_close_request(r, 0); | 1523 ngx_http_close_request(r, 0); |
1524 c->data = hc; | |
1519 | 1525 |
1520 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 1526 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
1521 ngx_add_timer(rev, clcf->keepalive_timeout); | 1527 ngx_add_timer(rev, clcf->keepalive_timeout); |
1522 | 1528 |
1523 if (ngx_handle_level_read_event(rev) == NGX_ERROR) { | 1529 if (ngx_handle_level_read_event(rev) == NGX_ERROR) { |
1551 b->last = b->start + len; | 1557 b->last = b->start + len; |
1552 } | 1558 } |
1553 | 1559 |
1554 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "pipelined request"); | 1560 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, c->log, 0, "pipelined request"); |
1555 | 1561 |
1556 c->pipeline = 1; | 1562 hc->pipeline = 1; |
1557 ctx->action = "reading client pipelined request line"; | 1563 ctx->action = "reading client pipelined request line"; |
1558 ngx_http_init_request(rev); | 1564 ngx_http_init_request(rev); |
1559 return; | 1565 return; |
1560 } | 1566 } |
1561 | 1567 |
1562 c->pipeline = 0; | 1568 hc->pipeline = 0; |
1563 | 1569 |
1564 b->pos = b->last = b->start; | 1570 b->pos = b->last = b->start; |
1565 rev->event_handler = ngx_http_keepalive_handler; | 1571 rev->event_handler = ngx_http_keepalive_handler; |
1566 | 1572 |
1567 if (wev->active) { | 1573 if (wev->active) { |
1646 } | 1652 } |
1647 | 1653 |
1648 c->buffer->last += n; | 1654 c->buffer->last += n; |
1649 rev->log->handler = ngx_http_log_error; | 1655 rev->log->handler = ngx_http_log_error; |
1650 ctx->action = "reading client request line"; | 1656 ctx->action = "reading client request line"; |
1657 | |
1658 #if 0 | |
1659 if (!(hc = ngx_pcalloc(c->pool, sizeof(ngx_http_connection_t)) { | |
1660 ngx_http_close_connection(c); | |
1661 return; | |
1662 } | |
1663 | |
1664 hc->request = r; | |
1665 c->data = r; | |
1666 #endif | |
1651 | 1667 |
1652 ngx_http_init_request(rev); | 1668 ngx_http_init_request(rev); |
1653 } | 1669 } |
1654 | 1670 |
1655 | 1671 |