Mercurial > hg > nginx-quic
comparison src/http/ngx_http_request.c @ 290:87e73f067470
nginx-0.0.2-2004-03-16-10:10:12 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 16 Mar 2004 07:10:12 +0000 |
parents | 35a6a9df2d25 |
children | 117ccc7c4055 |
comparison
equal
deleted
inserted
replaced
289:0750faf8d7e3 | 290:87e73f067470 |
---|---|
113 } | 113 } |
114 | 114 |
115 | 115 |
116 static void ngx_http_init_request(ngx_event_t *rev) | 116 static void ngx_http_init_request(ngx_event_t *rev) |
117 { | 117 { |
118 ngx_int_t i; | 118 ngx_uint_t i; |
119 socklen_t len; | 119 socklen_t len; |
120 struct sockaddr_in addr_in; | 120 struct sockaddr_in addr_in; |
121 ngx_connection_t *c; | 121 ngx_connection_t *c; |
122 ngx_http_request_t *r; | 122 ngx_http_request_t *r; |
123 ngx_http_in_port_t *in_port; | 123 ngx_http_in_port_t *in_port; |
180 ngx_log_error(NGX_LOG_CRIT, rev->log, ngx_socket_errno, | 180 ngx_log_error(NGX_LOG_CRIT, rev->log, ngx_socket_errno, |
181 "getsockname() failed"); | 181 "getsockname() failed"); |
182 ngx_http_close_connection(c); | 182 ngx_http_close_connection(c); |
183 return; | 183 return; |
184 } | 184 } |
185 | |
186 r->in_addr = addr_in.sin_addr.s_addr; | |
187 | |
185 #if (WIN32) | 188 #if (WIN32) |
186 } | 189 } |
187 #endif | 190 #endif |
188 | |
189 r->in_addr = addr_in.sin_addr.s_addr; | |
190 | 191 |
191 /* the last in_port->addrs address is "*" */ | 192 /* the last in_port->addrs address is "*" */ |
192 | 193 |
193 for ( /* void */ ; i < in_port->addrs.nelts - 1; i++) { | 194 for ( /* void */ ; i < in_port->addrs.nelts - 1; i++) { |
194 if (in_addr[i].addr == r->in_addr) { | 195 if (in_addr[i].addr == r->in_addr) { |
277 } | 278 } |
278 | 279 |
279 | 280 |
280 static void ngx_http_process_request_line(ngx_event_t *rev) | 281 static void ngx_http_process_request_line(ngx_event_t *rev) |
281 { | 282 { |
282 char *p; | 283 u_char *p; |
283 ssize_t n; | 284 ssize_t n; |
284 ngx_int_t rc, offset; | 285 ngx_int_t rc, offset; |
285 ngx_connection_t *c; | 286 ngx_connection_t *c; |
286 ngx_http_request_t *r; | 287 ngx_http_request_t *r; |
287 ngx_http_log_ctx_t *ctx; | 288 ngx_http_log_ctx_t *ctx; |
451 | 452 |
452 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | 453 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
453 "http uri: \"%s\"", r->uri.data); | 454 "http uri: \"%s\"", r->uri.data); |
454 | 455 |
455 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | 456 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
456 "http args: \"%s\"", r->args.data ? r->args.data : ""); | 457 "http args: \"%s\"", |
458 r->args.data ? r->args.data : (u_char *) ""); | |
457 | 459 |
458 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | 460 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
459 "http exten: \"%s\"", | 461 "http exten: \"%s\"", |
460 r->exten.data ? r->exten.data : ""); | 462 r->exten.data ? r->exten.data : (u_char *) ""); |
461 | 463 |
462 if (r->http_version < NGX_HTTP_VERSION_10) { | 464 if (r->http_version < NGX_HTTP_VERSION_10) { |
463 rev->event_handler = ngx_http_block_read; | 465 rev->event_handler = ngx_http_block_read; |
464 ngx_http_handler(r); | 466 ngx_http_handler(r); |
465 return; | 467 return; |
679 | 681 |
680 /* there was error while a header line parsing */ | 682 /* there was error while a header line parsing */ |
681 | 683 |
682 #if (NGX_LOG_DEBUG) | 684 #if (NGX_LOG_DEBUG) |
683 if (rc == NGX_HTTP_PARSE_INVALID_HEADER) { | 685 if (rc == NGX_HTTP_PARSE_INVALID_HEADER) { |
684 char *p; | 686 u_char *p; |
685 for (p = r->header_name_start; | 687 for (p = r->header_name_start; |
686 p < r->header_in->last - 1; | 688 p < r->header_in->last - 1; |
687 p++) | 689 p++) |
688 { | 690 { |
689 if (*p == LF) { | 691 if (*p == LF) { |
792 | 794 |
793 | 795 |
794 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r) | 796 static ngx_int_t ngx_http_process_request_header(ngx_http_request_t *r) |
795 { | 797 { |
796 size_t len; | 798 size_t len; |
797 ngx_int_t i; | 799 ngx_uint_t i; |
798 ngx_http_server_name_t *name; | 800 ngx_http_server_name_t *name; |
799 ngx_http_core_loc_conf_t *clcf; | 801 ngx_http_core_loc_conf_t *clcf; |
800 | 802 |
801 if (r->headers_in.host) { | 803 if (r->headers_in.host) { |
802 for (len = 0; len < r->headers_in.host->value.len; len++) { | 804 for (len = 0; len < r->headers_in.host->value.len; len++) { |
1131 } | 1133 } |
1132 } | 1134 } |
1133 | 1135 |
1134 size = r->headers_in.content_length_n; | 1136 size = r->headers_in.content_length_n; |
1135 | 1137 |
1136 if (size > clcf->discarded_buffer_size) { | 1138 if (size > (ssize_t) clcf->discarded_buffer_size) { |
1137 size = clcf->discarded_buffer_size; | 1139 size = (ssize_t) clcf->discarded_buffer_size; |
1138 } | 1140 } |
1139 | 1141 |
1140 n = ngx_recv(r->connection, r->discarded_buffer, size); | 1142 n = ngx_recv(r->connection, r->discarded_buffer, size); |
1141 if (n == NGX_ERROR) { | 1143 if (n == NGX_ERROR) { |
1142 return NGX_HTTP_BAD_REQUEST; | 1144 return NGX_HTTP_BAD_REQUEST; |
1394 /* TODO: r->header_in->start (if large headers are enabled) | 1396 /* TODO: r->header_in->start (if large headers are enabled) |
1395 or the end of parsed header (otherwise) | 1397 or the end of parsed header (otherwise) |
1396 instead of r->header_in->last */ | 1398 instead of r->header_in->last */ |
1397 | 1399 |
1398 if (r->header_in->end - r->header_in->last | 1400 if (r->header_in->end - r->header_in->last |
1399 >= clcf->discarded_buffer_size) { | 1401 >= (ssize_t) clcf->discarded_buffer_size) |
1402 { | |
1400 r->discarded_buffer = r->header_in->last; | 1403 r->discarded_buffer = r->header_in->last; |
1401 | 1404 |
1402 } else { | 1405 } else { |
1403 r->discarded_buffer = ngx_palloc(c->pool, | 1406 r->discarded_buffer = ngx_palloc(c->pool, |
1404 clcf->discarded_buffer_size); | 1407 clcf->discarded_buffer_size); |
1456 } | 1459 } |
1457 | 1460 |
1458 | 1461 |
1459 void ngx_http_close_request(ngx_http_request_t *r, int error) | 1462 void ngx_http_close_request(ngx_http_request_t *r, int error) |
1460 { | 1463 { |
1461 ngx_int_t i; | 1464 ngx_uint_t i; |
1462 ngx_log_t *log; | 1465 ngx_log_t *log; |
1463 ngx_http_log_ctx_t *ctx; | 1466 ngx_http_log_ctx_t *ctx; |
1464 ngx_http_cleanup_t *cleanup; | 1467 ngx_http_cleanup_t *cleanup; |
1465 | 1468 |
1466 log = r->connection->log; | 1469 log = r->connection->log; |
1557 if (ngx_close_socket(c->fd) == -1) { | 1560 if (ngx_close_socket(c->fd) == -1) { |
1558 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_socket_errno, | 1561 ngx_log_error(NGX_LOG_ALERT, c->log, ngx_socket_errno, |
1559 ngx_close_socket_n " failed"); | 1562 ngx_close_socket_n " failed"); |
1560 } | 1563 } |
1561 | 1564 |
1562 c->fd = -1; | 1565 c->fd = (ngx_socket_t) -1; |
1563 c->data = NULL; | 1566 c->data = NULL; |
1564 | 1567 |
1565 ngx_destroy_pool(c->pool); | 1568 ngx_destroy_pool(c->pool); |
1566 | 1569 |
1567 return; | 1570 return; |