comparison src/http/ngx_http_core_module.c @ 644:6f21ae02fb01 NGINX_1_1_6

nginx 1.1.6 *) Change in internal API: now module context data are cleared while internal redirect to named location. Requested by Yichun Zhang. *) Change: if a server in an upstream failed, only one request will be sent to it after fail_timeout; the server will be considered alive if it will successfully respond to the request. *) Change: now the 0x7F-0x1F characters are escaped as \xXX in an access_log. *) Feature: "proxy/fastcgi/scgi/uwsgi_ignore_headers" directives support the following additional values: X-Accel-Limit-Rate, X-Accel-Buffering, X-Accel-Charset. *) Feature: decrease of memory consumption if SSL is used. *) Bugfix: some UTF-8 characters were processed incorrectly. Thanks to Alexey Kuts. *) Bugfix: the ngx_http_rewrite_module directives specified at "server" level were executed twice if no matching locations were defined. *) Bugfix: a socket leak might occurred if "aio sendfile" was used. *) Bugfix: connections with fast clients might be closed after send_timeout if file AIO was used. *) Bugfix: in the ngx_http_autoindex_module. *) Bugfix: the module ngx_http_mp4_module did not support seeking on 32-bit platforms.
author Igor Sysoev <http://sysoev.ru>
date Mon, 17 Oct 2011 00:00:00 +0400
parents d3cf6c6b0043
children 615b5ea36fc0
comparison
equal deleted inserted replaced
643:a4bb0b481f6c 644:6f21ae02fb01
981 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE); 981 ngx_http_finalize_request(r, NGX_HTTP_REQUEST_ENTITY_TOO_LARGE);
982 return NGX_OK; 982 return NGX_OK;
983 } 983 }
984 984
985 if (rc == NGX_DONE) { 985 if (rc == NGX_DONE) {
986 ngx_http_clear_location(r);
987
986 r->headers_out.location = ngx_list_push(&r->headers_out.headers); 988 r->headers_out.location = ngx_list_push(&r->headers_out.headers);
987 if (r->headers_out.location == NULL) { 989 if (r->headers_out.location == NULL) {
988 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR); 990 ngx_http_finalize_request(r, NGX_HTTP_INTERNAL_SERVER_ERROR);
989 return NGX_OK; 991 return NGX_OK;
990 } 992 }
1794 return NGX_HTTP_INTERNAL_SERVER_ERROR; 1796 return NGX_HTTP_INTERNAL_SERVER_ERROR;
1795 } 1797 }
1796 1798
1797 if (status >= NGX_HTTP_MOVED_PERMANENTLY && status <= NGX_HTTP_SEE_OTHER) { 1799 if (status >= NGX_HTTP_MOVED_PERMANENTLY && status <= NGX_HTTP_SEE_OTHER) {
1798 1800
1801 ngx_http_clear_location(r);
1802
1799 r->headers_out.location = ngx_list_push(&r->headers_out.headers); 1803 r->headers_out.location = ngx_list_push(&r->headers_out.headers);
1800 if (r->headers_out.location == NULL) { 1804 if (r->headers_out.location == NULL) {
1801 return NGX_HTTP_INTERNAL_SERVER_ERROR; 1805 return NGX_HTTP_INTERNAL_SERVER_ERROR;
1802 } 1806 }
1803 1807
2539 name, &r->uri, &r->args); 2543 name, &r->uri, &r->args);
2540 2544
2541 r->internal = 1; 2545 r->internal = 1;
2542 r->content_handler = NULL; 2546 r->content_handler = NULL;
2543 r->loc_conf = (*clcfp)->loc_conf; 2547 r->loc_conf = (*clcfp)->loc_conf;
2548
2549 /* clear the modules contexts */
2550 ngx_memzero(r->ctx, sizeof(void *) * ngx_http_max_module);
2544 2551
2545 ngx_http_update_location_config(r); 2552 ngx_http_update_location_config(r);
2546 2553
2547 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); 2554 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
2548 2555
2992 ngx_hash_key_t *type; 2999 ngx_hash_key_t *type;
2993 3000
2994 value = cf->args->elts; 3001 value = cf->args->elts;
2995 3002
2996 if (ngx_strcmp(value[0].data, "include") == 0) { 3003 if (ngx_strcmp(value[0].data, "include") == 0) {
3004 if (cf->args->nelts != 2) {
3005 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3006 "invalid number of arguments"
3007 " in \"include\" directive");
3008 return NGX_CONF_ERROR;
3009 }
2997 file = value[1]; 3010 file = value[1];
2998 3011
2999 if (ngx_conf_full_name(cf->cycle, &file, 1) != NGX_OK) { 3012 if (ngx_conf_full_name(cf->cycle, &file, 1) != NGX_OK) {
3000 return NGX_CONF_ERROR; 3013 return NGX_CONF_ERROR;
3001 } 3014 }
3025 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, 3038 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
3026 "duplicate extension \"%V\", " 3039 "duplicate extension \"%V\", "
3027 "content type: \"%V\", " 3040 "content type: \"%V\", "
3028 "previous content type: \"%V\"", 3041 "previous content type: \"%V\"",
3029 &value[i], content_type, old); 3042 &value[i], content_type, old);
3030 continue; 3043 goto next;
3031 } 3044 }
3032 } 3045 }
3033 3046
3034 3047
3035 type = ngx_array_push(clcf->types); 3048 type = ngx_array_push(clcf->types);
3038 } 3051 }
3039 3052
3040 type->key = value[i]; 3053 type->key = value[i];
3041 type->key_hash = hash; 3054 type->key_hash = hash;
3042 type->value = content_type; 3055 type->value = content_type;
3056
3057 next:
3058 continue;
3043 } 3059 }
3044 3060
3045 return NGX_CONF_OK; 3061 return NGX_CONF_OK;
3046 } 3062 }
3047 3063
3371 3387
3372 conf->types_hash_bucket_size = ngx_align(conf->types_hash_bucket_size, 3388 conf->types_hash_bucket_size = ngx_align(conf->types_hash_bucket_size,
3373 ngx_cacheline_size); 3389 ngx_cacheline_size);
3374 3390
3375 /* 3391 /*
3376 * the special handling the "types" directive in the "http" section 3392 * the special handling of the "types" directive in the "http" section
3377 * to inherit the http's conf->types_hash to all servers 3393 * to inherit the http's conf->types_hash to all servers
3378 */ 3394 */
3379 3395
3380 if (prev->types && prev->types_hash.buckets == NULL) { 3396 if (prev->types && prev->types_hash.buckets == NULL) {
3381 3397
3398 conf->types = prev->types; 3414 conf->types = prev->types;
3399 conf->types_hash = prev->types_hash; 3415 conf->types_hash = prev->types_hash;
3400 } 3416 }
3401 3417
3402 if (conf->types == NULL) { 3418 if (conf->types == NULL) {
3403 conf->types = ngx_array_create(cf->pool, 4, sizeof(ngx_hash_key_t)); 3419 conf->types = ngx_array_create(cf->pool, 3, sizeof(ngx_hash_key_t));
3404 if (conf->types == NULL) { 3420 if (conf->types == NULL) {
3405 return NGX_CONF_ERROR; 3421 return NGX_CONF_ERROR;
3406 } 3422 }
3407 3423
3408 for (i = 0; ngx_http_core_default_types[i].key.len; i++) { 3424 for (i = 0; ngx_http_core_default_types[i].key.len; i++) {
3423 3439
3424 types_hash.hash = &conf->types_hash; 3440 types_hash.hash = &conf->types_hash;
3425 types_hash.key = ngx_hash_key_lc; 3441 types_hash.key = ngx_hash_key_lc;
3426 types_hash.max_size = conf->types_hash_max_size; 3442 types_hash.max_size = conf->types_hash_max_size;
3427 types_hash.bucket_size = conf->types_hash_bucket_size; 3443 types_hash.bucket_size = conf->types_hash_bucket_size;
3428 types_hash.name = "mime_types_hash"; 3444 types_hash.name = "types_hash";
3429 types_hash.pool = cf->pool; 3445 types_hash.pool = cf->pool;
3430 types_hash.temp_pool = NULL; 3446 types_hash.temp_pool = NULL;
3431 3447
3432 if (ngx_hash_init(&types_hash, conf->types->elts, conf->types->nelts) 3448 if (ngx_hash_init(&types_hash, conf->types->elts, conf->types->nelts)
3433 != NGX_OK) 3449 != NGX_OK)
3465 ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy, 3481 ngx_conf_merge_uint_value(conf->satisfy, prev->satisfy,
3466 NGX_HTTP_SATISFY_ALL); 3482 NGX_HTTP_SATISFY_ALL);
3467 ngx_conf_merge_uint_value(conf->if_modified_since, prev->if_modified_since, 3483 ngx_conf_merge_uint_value(conf->if_modified_since, prev->if_modified_since,
3468 NGX_HTTP_IMS_EXACT); 3484 NGX_HTTP_IMS_EXACT);
3469 ngx_conf_merge_uint_value(conf->max_ranges, prev->max_ranges, 3485 ngx_conf_merge_uint_value(conf->max_ranges, prev->max_ranges,
3470 0x7fffffff); 3486 NGX_MAX_INT32_VALUE);
3471 ngx_conf_merge_uint_value(conf->client_body_in_file_only, 3487 ngx_conf_merge_uint_value(conf->client_body_in_file_only,
3472 prev->client_body_in_file_only, 0); 3488 prev->client_body_in_file_only,
3489 NGX_HTTP_REQUEST_BODY_FILE_OFF);
3473 ngx_conf_merge_value(conf->client_body_in_single_buffer, 3490 ngx_conf_merge_value(conf->client_body_in_single_buffer,
3474 prev->client_body_in_single_buffer, 0); 3491 prev->client_body_in_single_buffer, 0);
3475 ngx_conf_merge_value(conf->internal, prev->internal, 0); 3492 ngx_conf_merge_value(conf->internal, prev->internal, 0);
3476 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0); 3493 ngx_conf_merge_value(conf->sendfile, prev->sendfile, 0);
3477 ngx_conf_merge_size_value(conf->sendfile_max_chunk, 3494 ngx_conf_merge_size_value(conf->sendfile_max_chunk,
3478 prev->sendfile_max_chunk, 0); 3495 prev->sendfile_max_chunk, 0);
3479 #if (NGX_HAVE_FILE_AIO) 3496 #if (NGX_HAVE_FILE_AIO)
3480 ngx_conf_merge_value(conf->aio, prev->aio, 0); 3497 ngx_conf_merge_value(conf->aio, prev->aio, NGX_HTTP_AIO_OFF);
3481 #endif 3498 #endif
3482 ngx_conf_merge_size_value(conf->read_ahead, prev->read_ahead, 0); 3499 ngx_conf_merge_size_value(conf->read_ahead, prev->read_ahead, 0);
3483 ngx_conf_merge_off_value(conf->directio, prev->directio, 3500 ngx_conf_merge_off_value(conf->directio, prev->directio,
3484 NGX_MAX_OFF_T_VALUE); 3501 NGX_OPEN_FILE_DIRECTIO_OFF);
3485 ngx_conf_merge_off_value(conf->directio_alignment, prev->directio_alignment, 3502 ngx_conf_merge_off_value(conf->directio_alignment, prev->directio_alignment,
3486 512); 3503 512);
3487 ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0); 3504 ngx_conf_merge_value(conf->tcp_nopush, prev->tcp_nopush, 0);
3488 ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 1); 3505 ngx_conf_merge_value(conf->tcp_nodelay, prev->tcp_nodelay, 1);
3489 3506
3837 ngx_conf_log_error(NGX_LOG_WARN, cf, 0, 3854 ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
3838 "server name \"%V\" has suspicious symbols", 3855 "server name \"%V\" has suspicious symbols",
3839 &value[i]); 3856 &value[i]);
3840 } 3857 }
3841 3858
3842 if (value[i].len == 1 && ch == '*') {
3843 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
3844 "\"server_name *\" is unsupported, use "
3845 "\"server_name_in_redirect off\" instead");
3846 return NGX_CONF_ERROR;
3847 }
3848
3849 sn = ngx_array_push(&cscf->server_names); 3859 sn = ngx_array_push(&cscf->server_names);
3850 if (sn == NULL) { 3860 if (sn == NULL) {
3851 return NGX_CONF_ERROR; 3861 return NGX_CONF_ERROR;
3852 } 3862 }
3853 3863