comparison src/http/ngx_http_event.c @ 71:59229033ae93

nginx-0.0.1-2003-04-08-19:40:10 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 08 Apr 2003 15:40:10 +0000
parents e43f406e4525
children 66de3f065886
comparison
equal deleted inserted replaced
70:e320bf51c4e3 71:59229033ae93
236 } 236 }
237 237
238 r->header_in->last += n; 238 r->header_in->last += n;
239 } 239 }
240 240
241 /* the state_handlers are called in the following order: 241 /* the state handlers are called in the following order:
242 ngx_http_process_request_line(r) 242 ngx_http_process_request_line(r)
243 ngx_http_process_request_headers(r) */ 243 ngx_http_process_request_headers(r) */
244 244
245 do { 245 do {
246 rc = (r->state_handler)(r); 246 rc = r->state_handler(r);
247 247
248 } while (rc == NGX_AGAIN && r->header_in->pos < r->header_in->last); 248 } while (rc == NGX_AGAIN && r->header_in->pos < r->header_in->last);
249 249
250 } while (rc == NGX_AGAIN 250 } while (rc == NGX_AGAIN
251 && (rev->ready || ngx_event_flags & NGX_HAVE_AIO_EVENT)); 251 && (rev->ready || ngx_event_flags & NGX_HAVE_AIO_EVENT));
263 lcx = r->connection->log->data; 263 lcx = r->connection->log->data;
264 lcx->action = "processing client request"; 264 lcx->action = "processing client request";
265 265
266 rc = ngx_http_handler(r); 266 rc = ngx_http_handler(r);
267 267
268 /* a handler is still busy */ 268 /* a handler does its own processing */
269 if (rc == NGX_BUSY) { 269 if (rc == NGX_DONE) {
270 return rc; 270 return rc;
271 } 271 }
272 272
273 if (rc == NGX_ERROR) { 273 if (rc == NGX_ERROR) {
274 rc = NGX_HTTP_INTERNAL_SERVER_ERROR; 274 rc = NGX_HTTP_INTERNAL_SERVER_ERROR;
308 308
309 /* a request line has been parsed successfully */ 309 /* a request line has been parsed successfully */
310 310
311 if (rc == NGX_OK) { 311 if (rc == NGX_OK) {
312 312
313 if (r->http_version >= NGX_HTTP_VERSION_10
314 && ngx_http_large_client_header == 0
315 && r->header_in->pos == r->header_in->end)
316 {
317 ngx_http_header_parse_error(r, NGX_HTTP_PARSE_TOO_LONG_URI);
318 return NGX_HTTP_REQUEST_URI_TOO_LARGE;
319 }
320
313 /* copy URI */ 321 /* copy URI */
314 322
315 if (r->args_start) { 323 if (r->args_start) {
316 r->uri.len = r->args_start - 1 - r->uri_start; 324 r->uri.len = r->args_start - 1 - r->uri_start;
317 } else { 325 } else {
327 335
328 /* if the large client headers are enabled then 336 /* if the large client headers are enabled then
329 we need to copy a request line */ 337 we need to copy a request line */
330 338
331 if (ngx_http_large_client_header) { 339 if (ngx_http_large_client_header) {
332
333 ngx_test_null(r->request_line.data, 340 ngx_test_null(r->request_line.data,
334 ngx_palloc(r->pool, r->request_line.len + 1), 341 ngx_palloc(r->pool, r->request_line.len + 1),
335 NGX_HTTP_INTERNAL_SERVER_ERROR); 342 NGX_HTTP_INTERNAL_SERVER_ERROR);
336 343
337 ngx_cpystrn(r->request_line.data, r->request_start, 344 ngx_cpystrn(r->request_line.data, r->request_start,
649 656
650 /* NGX_AGAIN: a handler has done its work 657 /* NGX_AGAIN: a handler has done its work
651 but the transfer is still not completed */ 658 but the transfer is still not completed */
652 659
653 lcf = (ngx_http_core_loc_conf_t *) 660 lcf = (ngx_http_core_loc_conf_t *)
654 ngx_http_get_module_loc_conf(r->main ? r->main : r, 661 ngx_http_get_module_loc_conf(r->main ? r->main : r,
655 ngx_http_core_module); 662 ngx_http_core_module_ctx);
656 wev = r->connection->write; 663 wev = r->connection->write;
657 wev->event_handler = ngx_http_writer; 664 wev->event_handler = ngx_http_writer;
658 wev->timer_set = 1; 665 wev->timer_set = 1;
659 ngx_add_timer(wev, lcf->send_timeout); 666 ngx_add_timer(wev, lcf->send_timeout);
660 667
723 ngx_log_debug(c->log, "output filter in writer: %d" _ rc); 730 ngx_log_debug(c->log, "output filter in writer: %d" _ rc);
724 731
725 if (rc == NGX_AGAIN) { 732 if (rc == NGX_AGAIN) {
726 733
727 lcf = (ngx_http_core_loc_conf_t *) 734 lcf = (ngx_http_core_loc_conf_t *)
728 ngx_http_get_module_loc_conf(r->main ? r->main : r, 735 ngx_http_get_module_loc_conf(r->main ? r->main : r,
729 ngx_http_core_module); 736 ngx_http_core_module_ctx);
730 if (wev->timer_set) { 737 if (wev->timer_set) {
731 ngx_del_timer(wev); 738 ngx_del_timer(wev);
732 } else { 739 } else {
733 wev->timer_set = 1; 740 wev->timer_set = 1;
734 } 741 }
822 829
823 c = (ngx_connection_t *) ev->data; 830 c = (ngx_connection_t *) ev->data;
824 r = (ngx_http_request_t *) c->data; 831 r = (ngx_http_request_t *) c->data;
825 832
826 lcf = (ngx_http_core_loc_conf_t *) 833 lcf = (ngx_http_core_loc_conf_t *)
827 ngx_http_get_module_loc_conf(r, ngx_http_core_module); 834 ngx_http_get_module_loc_conf(r, ngx_http_core_module_ctx);
828 835
829 if (r->discarded_buffer == NULL) { 836 if (r->discarded_buffer == NULL) {
830 ngx_test_null(r->discarded_buffer, 837 ngx_test_null(r->discarded_buffer,
831 ngx_palloc(r->pool, lcf->discarded_buffer_size), 838 ngx_palloc(r->pool, lcf->discarded_buffer_size),
832 NGX_ERROR); 839 NGX_ERROR);
942 c = (ngx_connection_t *) rev->data; 949 c = (ngx_connection_t *) rev->data;
943 950
944 ngx_log_debug(c->log, "http keepalive handler"); 951 ngx_log_debug(c->log, "http keepalive handler");
945 952
946 if (rev->timedout) { 953 if (rev->timedout) {
947 return NGX_DONE; 954 return NGX_ERROR; /* to close connection */
948 } 955 }
949 956
950 /* MSIE closes a keepalive connection with RST flag 957 /* MSIE closes a keepalive connection with RST flag
951 so we ignore ECONNRESET here */ 958 so we ignore ECONNRESET here */
952 959
963 rev->log->handler = NULL; 970 rev->log->handler = NULL;
964 971
965 if (n == 0) { 972 if (n == 0) {
966 ngx_log_error(NGX_LOG_INFO, c->log, ngx_socket_errno, 973 ngx_log_error(NGX_LOG_INFO, c->log, ngx_socket_errno,
967 "client %s closed keepalive connection", lctx->client); 974 "client %s closed keepalive connection", lctx->client);
968 return NGX_DONE; 975 return NGX_ERROR; /* to close connection */
969 } 976 }
970 977
971 c->buffer->last += n; 978 c->buffer->last += n;
972 rev->log->handler = ngx_http_log_error; 979 rev->log->handler = ngx_http_log_error;
973 lctx->action = "reading client request line"; 980 lctx->action = "reading client request line";
984 991
985 c = r->connection; 992 c = r->connection;
986 rev = c->read; 993 rev = c->read;
987 994
988 lcf = (ngx_http_core_loc_conf_t *) 995 lcf = (ngx_http_core_loc_conf_t *)
989 ngx_http_get_module_loc_conf(r, ngx_http_core_module); 996 ngx_http_get_module_loc_conf(r, ngx_http_core_module_ctx);
990 997
991 r->lingering_time = ngx_time() + lcf->lingering_time / 1000; 998 r->lingering_time = ngx_time() + lcf->lingering_time / 1000;
992 r->connection->read->event_handler = ngx_http_lingering_close_handler; 999 r->connection->read->event_handler = ngx_http_lingering_close_handler;
993 1000
994 if (rev->timer_set) { 1001 if (rev->timer_set) {
1061 if (timer <= 0) { 1068 if (timer <= 0) {
1062 return ngx_http_close_request(r, 0); 1069 return ngx_http_close_request(r, 0);
1063 } 1070 }
1064 1071
1065 lcf = (ngx_http_core_loc_conf_t *) 1072 lcf = (ngx_http_core_loc_conf_t *)
1066 ngx_http_get_module_loc_conf(r, ngx_http_core_module); 1073 ngx_http_get_module_loc_conf(r, ngx_http_core_module_ctx);
1067 1074
1068 if (r->discarded_buffer == NULL) { 1075 if (r->discarded_buffer == NULL) {
1069 1076
1070 /* TODO: r->header_in->start (if large headers are enabled) 1077 /* TODO: r->header_in->start (if large headers are enabled)
1071 or the end of parsed header (otherwise) 1078 or the end of parsed header (otherwise)