comparison src/http/ngx_http_core_module.c @ 92:45945fa8b8ba NGINX_0_2_0

nginx 0.2.0 *) The pid-file names used during online upgrade was changed and now is not required a manual rename operation. The old master process adds the ".oldbin" suffix to its pid-file and executes a new binary file. The new master process creates usual pid-file without the ".newbin" suffix. If the master process exits, then old master process renames back its pid-file with the ".oldbin" suffix to the pid-file without suffix. *) Change: the "worker_connections" directive, new name of the "connections" directive; now the directive specifies maximum number of connections, but not maximum socket descriptor number. *) Feature: SSL supports the session cache inside one worker process. *) Feature: the "satisfy_any" directive. *) Change: the ngx_http_access_module and ngx_http_auth_basic_module do not run for subrequests. *) Feature: the "worker_rlimit_nofile" and "worker_rlimit_sigpending" directives. *) Bugfix: if all backend using in load-balancing failed after one error, then nginx did not try do connect to them during 60 seconds. *) Bugfix: in IMAP/POP3 command argument parsing. Thanks to Rob Mueller. *) Bugfix: errors while using SSL in IMAP/POP3 proxy. *) Bugfix: errors while using SSI and gzipping. *) Bugfix: the "Expires" and "Cache-Control" header lines were omitted from the 304 responses. Thanks to Alexandr Kukushkin.
author Igor Sysoev <http://sysoev.ru>
date Fri, 23 Sep 2005 00:00:00 +0400
parents 71c46860eb55
children f63280c59dd5
comparison
equal deleted inserted replaced
91:c3eee83ea942 92:45945fa8b8ba
280 { ngx_string("keepalive_timeout"), 280 { ngx_string("keepalive_timeout"),
281 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12, 281 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE12,
282 ngx_http_core_keepalive, 282 ngx_http_core_keepalive,
283 NGX_HTTP_LOC_CONF_OFFSET, 283 NGX_HTTP_LOC_CONF_OFFSET,
284 0, 284 0,
285 NULL },
286
287 { ngx_string("satisfy_any"),
288 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
289 ngx_conf_set_flag_slot,
290 NGX_HTTP_LOC_CONF_OFFSET,
291 offsetof(ngx_http_core_loc_conf_t, satisfy_any),
285 NULL }, 292 NULL },
286 293
287 { ngx_string("internal"), 294 { ngx_string("internal"),
288 NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS, 295 NGX_HTTP_LOC_CONF|NGX_CONF_NOARGS,
289 ngx_http_core_internal, 296 ngx_http_core_internal,
399 { 406 {
400 r->connection->log->action = NULL; 407 r->connection->log->action = NULL;
401 408
402 r->connection->unexpected_eof = 0; 409 r->connection->unexpected_eof = 0;
403 410
404 switch (r->headers_in.connection_type) { 411 if (r->err_ctx == NULL) {
405 case 0: 412 switch (r->headers_in.connection_type) {
406 if (r->http_version > NGX_HTTP_VERSION_10) { 413 case 0:
414 if (r->http_version > NGX_HTTP_VERSION_10) {
415 r->keepalive = 1;
416 } else {
417 r->keepalive = 0;
418 }
419 break;
420
421 case NGX_HTTP_CONNECTION_CLOSE:
422 r->keepalive = 0;
423 break;
424
425 case NGX_HTTP_CONNECTION_KEEP_ALIVE:
407 r->keepalive = 1; 426 r->keepalive = 1;
427 break;
428 }
429
430 if (r->keepalive && r->headers_in.msie && r->method == NGX_HTTP_POST) {
431
432 /*
433 * MSIE may wait for some time if the response for the POST request
434 * is sent over the keepalive connection
435 */
436
437 r->keepalive = 0;
438 }
439
440 if (r->headers_in.content_length_n > 0) {
441 r->lingering_close = 1;
442
408 } else { 443 } else {
409 r->keepalive = 0; 444 r->lingering_close = 0;
410 } 445 }
411 break; 446 }
412
413 case NGX_HTTP_CONNECTION_CLOSE:
414 r->keepalive = 0;
415 break;
416
417 case NGX_HTTP_CONNECTION_KEEP_ALIVE:
418 r->keepalive = 1;
419 break;
420 }
421
422 if (r->keepalive && r->headers_in.msie && r->method == NGX_HTTP_POST) {
423
424 /*
425 * MSIE may wait for some time if the response for the POST request
426 * is sent over the keepalive connection
427 */
428
429 r->keepalive = 0;
430 }
431
432 #if 0
433 /* TEST STUB */ r->http_version = NGX_HTTP_VERSION_10;
434 /* TEST STUB */ r->keepalive = 0;
435 #endif
436
437 if (r->headers_in.content_length_n > 0) {
438 r->lingering_close = 1;
439
440 } else {
441 r->lingering_close = 0;
442 }
443
444 #if 0
445 /* TEST STUB */ r->lingering_close = 1;
446 #endif
447 447
448 r->write_event_handler = ngx_http_core_run_phases; 448 r->write_event_handler = ngx_http_core_run_phases;
449 449
450 r->valid_unparsed_uri = 1; 450 r->valid_unparsed_uri = 1;
451 r->valid_location = 1; 451 r->valid_location = 1;
496 } 496 }
497 497
498 r->phase = NGX_HTTP_FIND_CONFIG_PHASE; 498 r->phase = NGX_HTTP_FIND_CONFIG_PHASE;
499 } 499 }
500 500
501 if (r->phase == NGX_HTTP_ACCESS_PHASE && r->main) {
502 continue;
503 }
504
501 if (r->phase == NGX_HTTP_CONTENT_PHASE && r->content_handler) { 505 if (r->phase == NGX_HTTP_CONTENT_PHASE && r->content_handler) {
502 r->write_event_handler = ngx_http_request_empty_handler; 506 r->write_event_handler = ngx_http_request_empty_handler;
503 ngx_http_finalize_request(r, r->content_handler(r)); 507 ngx_http_finalize_request(r, r->content_handler(r));
504 return; 508 return;
505 } 509 }
513 517
514 if (rc == NGX_DONE) { 518 if (rc == NGX_DONE) {
515 519
516 /* 520 /*
517 * we should never use r here because 521 * we should never use r here because
518 * it could point to already freed data 522 * it may point to already freed data
519 */ 523 */
520 524
521 return; 525 return;
522 } 526 }
523 527
524 if (rc == NGX_DECLINED) { 528 if (rc == NGX_DECLINED) {
525 continue; 529 continue;
530 }
531
532 if (r->phase == NGX_HTTP_ACCESS_PHASE) {
533 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
534
535 if (clcf->satisfy_any) {
536
537 if (rc == NGX_OK) {
538 r->access_code = 0;
539
540 if (r->headers_out.www_authenticate) {
541 r->headers_out.www_authenticate->hash = 0;
542 }
543
544 break;
545 }
546
547 if (rc == NGX_HTTP_FORBIDDEN || rc == NGX_HTTP_UNAUTHORIZED)
548 {
549 r->access_code = rc;
550
551 continue;
552 }
553 }
526 } 554 }
527 555
528 if (rc >= NGX_HTTP_SPECIAL_RESPONSE 556 if (rc >= NGX_HTTP_SPECIAL_RESPONSE
529 || rc == NGX_HTTP_NO_CONTENT 557 || rc == NGX_HTTP_NO_CONTENT
530 || rc == NGX_ERROR) 558 || rc == NGX_ERROR)
543 } 571 }
544 572
545 if (rc == NGX_OK && cmcf->phases[r->phase].type == NGX_OK) { 573 if (rc == NGX_OK && cmcf->phases[r->phase].type == NGX_OK) {
546 break; 574 break;
547 } 575 }
576
577 }
578
579 if (r->phase == NGX_HTTP_ACCESS_PHASE && r->access_code) {
580 ngx_http_finalize_request(r, r->access_code);
581 return;
548 } 582 }
549 } 583 }
550 584
551 /* no content handler was found */ 585 /* no content handler was found */
552 586
1100 r->postponed = pr; 1134 r->postponed = pr;
1101 } 1135 }
1102 1136
1103 sr->internal = 1; 1137 sr->internal = 1;
1104 1138
1139 sr->discard_body = r->discard_body;
1105 sr->main_filter_need_in_memory = r->main_filter_need_in_memory; 1140 sr->main_filter_need_in_memory = r->main_filter_need_in_memory;
1106 1141
1107 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 1142 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
1108 "http subrequest \"%V\"", uri); 1143 "http subrequest \"%V\"", uri);
1109 1144
1791 */ 1826 */
1792 1827
1793 lcf->client_max_body_size = NGX_CONF_UNSET_SIZE; 1828 lcf->client_max_body_size = NGX_CONF_UNSET_SIZE;
1794 lcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE; 1829 lcf->client_body_buffer_size = NGX_CONF_UNSET_SIZE;
1795 lcf->client_body_timeout = NGX_CONF_UNSET_MSEC; 1830 lcf->client_body_timeout = NGX_CONF_UNSET_MSEC;
1831 lcf->satisfy_any = NGX_CONF_UNSET;
1796 lcf->internal = NGX_CONF_UNSET; 1832 lcf->internal = NGX_CONF_UNSET;
1797 lcf->sendfile = NGX_CONF_UNSET; 1833 lcf->sendfile = NGX_CONF_UNSET;
1798 lcf->tcp_nopush = NGX_CONF_UNSET; 1834 lcf->tcp_nopush = NGX_CONF_UNSET;
1799 lcf->tcp_nodelay = NGX_CONF_UNSET; 1835 lcf->tcp_nodelay = NGX_CONF_UNSET;
1800 lcf->send_timeout = NGX_CONF_UNSET_MSEC; 1836 lcf->send_timeout = NGX_CONF_UNSET_MSEC;
1893 prev->client_body_buffer_size, 1929 prev->client_body_buffer_size,
1894 (size_t) 2 * ngx_pagesize); 1930 (size_t) 2 * ngx_pagesize);
1895 ngx_conf_merge_msec_value(conf->client_body_timeout, 1931 ngx_conf_merge_msec_value(conf->client_body_timeout,
1896 prev->client_body_timeout, 60000); 1932 prev->client_body_timeout, 60000);
1897 1933
1934 ngx_conf_merge_value(conf->satisfy_any, prev->satisfy_any, 0);
1898 ngx_conf_merge_value(conf->internal, prev->internal, 0); 1935 ngx_conf_merge_value(conf->internal, prev->internal, 0);
1899 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0); 1936 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0);
1900 ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0); 1937 ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0);
1901 ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 0); 1938 ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 0);
1902 1939