# HG changeset patch # User Igor Sysoev # Date 1259586910 0 # Node ID 6b8e5c882e478776ba0fd64da818e3eab63113fe # Parent 102fdc22de4d0018d34ba187a747e06aaa1a092c support "*" in gzip_types, ssi_types, etc diff --git a/src/http/modules/ngx_http_addition_filter_module.c b/src/http/modules/ngx_http_addition_filter_module.c --- a/src/http/modules/ngx_http_addition_filter_module.c +++ b/src/http/modules/ngx_http_addition_filter_module.c @@ -237,8 +237,8 @@ ngx_http_addition_merge_conf(ngx_conf_t ngx_conf_merge_str_value(conf->before_body, prev->before_body, ""); ngx_conf_merge_str_value(conf->after_body, prev->after_body, ""); - if (ngx_http_merge_types(cf, conf->types_keys, &conf->types, - prev->types_keys, &prev->types, + if (ngx_http_merge_types(cf, &conf->types_keys, &conf->types, + &prev->types_keys, &prev->types, ngx_http_html_default_types) != NGX_OK) { diff --git a/src/http/modules/ngx_http_charset_filter_module.c b/src/http/modules/ngx_http_charset_filter_module.c --- a/src/http/modules/ngx_http_charset_filter_module.c +++ b/src/http/modules/ngx_http_charset_filter_module.c @@ -1550,8 +1550,8 @@ ngx_http_charset_merge_loc_conf(ngx_conf ngx_http_charset_recode_t *recode; ngx_http_charset_main_conf_t *mcf; - if (ngx_http_merge_types(cf, conf->types_keys, &conf->types, - prev->types_keys, &prev->types, + if (ngx_http_merge_types(cf, &conf->types_keys, &conf->types, + &prev->types_keys, &prev->types, ngx_http_charset_default_types) != NGX_OK) { diff --git a/src/http/modules/ngx_http_gzip_filter_module.c b/src/http/modules/ngx_http_gzip_filter_module.c --- a/src/http/modules/ngx_http_gzip_filter_module.c +++ b/src/http/modules/ngx_http_gzip_filter_module.c @@ -1123,8 +1123,8 @@ ngx_http_gzip_merge_conf(ngx_conf_t *cf, MAX_MEM_LEVEL - 1); ngx_conf_merge_value(conf->min_length, prev->min_length, 20); - if (ngx_http_merge_types(cf, conf->types_keys, &conf->types, - prev->types_keys, &prev->types, + if (ngx_http_merge_types(cf, &conf->types_keys, &conf->types, + &prev->types_keys, &prev->types, ngx_http_html_default_types) != NGX_OK) { diff --git a/src/http/modules/ngx_http_ssi_filter_module.c b/src/http/modules/ngx_http_ssi_filter_module.c --- a/src/http/modules/ngx_http_ssi_filter_module.c +++ b/src/http/modules/ngx_http_ssi_filter_module.c @@ -2773,8 +2773,8 @@ ngx_http_ssi_merge_loc_conf(ngx_conf_t * ngx_conf_merge_size_value(conf->min_file_chunk, prev->min_file_chunk, 1024); ngx_conf_merge_size_value(conf->value_len, prev->value_len, 256); - if (ngx_http_merge_types(cf, conf->types_keys, &conf->types, - prev->types_keys, &prev->types, + if (ngx_http_merge_types(cf, &conf->types_keys, &conf->types, + &prev->types_keys, &prev->types, ngx_http_html_default_types) != NGX_OK) { diff --git a/src/http/modules/ngx_http_sub_filter_module.c b/src/http/modules/ngx_http_sub_filter_module.c --- a/src/http/modules/ngx_http_sub_filter_module.c +++ b/src/http/modules/ngx_http_sub_filter_module.c @@ -671,8 +671,8 @@ ngx_http_sub_merge_conf(ngx_conf_t *cf, conf->value = prev->value; } - if (ngx_http_merge_types(cf, conf->types_keys, &conf->types, - prev->types_keys, &prev->types, + if (ngx_http_merge_types(cf, &conf->types_keys, &conf->types, + &prev->types_keys, &prev->types, ngx_http_html_default_types) != NGX_OK) { diff --git a/src/http/modules/ngx_http_xslt_filter_module.c b/src/http/modules/ngx_http_xslt_filter_module.c --- a/src/http/modules/ngx_http_xslt_filter_module.c +++ b/src/http/modules/ngx_http_xslt_filter_module.c @@ -1230,8 +1230,8 @@ ngx_http_xslt_filter_merge_conf(ngx_conf conf->sheets = prev->sheets; } - if (ngx_http_merge_types(cf, conf->types_keys, &conf->types, - prev->types_keys, &prev->types, + if (ngx_http_merge_types(cf, &conf->types_keys, &conf->types, + &prev->types_keys, &prev->types, ngx_http_xslt_default_types) != NGX_OK) { diff --git a/src/http/ngx_http.c b/src/http/ngx_http.c --- a/src/http/ngx_http.c +++ b/src/http/ngx_http.c @@ -1854,6 +1854,10 @@ ngx_http_types_slot(ngx_conf_t *cf, ngx_ types = (ngx_array_t **) (p + cmd->offset); + if (*types == (void *) -1) { + return NGX_CONF_OK; + } + default_type = cmd->post; if (*types == NULL) { @@ -1879,6 +1883,11 @@ ngx_http_types_slot(ngx_conf_t *cf, ngx_ for (i = 1; i < cf->args->nelts; i++) { + if (value[i].len == 1 && value[i].data[0] == '*') { + *types = (void *) -1; + return NGX_CONF_OK; + } + hash = ngx_hash_strlow(value[i].data, value[i].data, value[i].len); value[i].data[value[i].len] = '\0'; @@ -1907,13 +1916,17 @@ ngx_http_types_slot(ngx_conf_t *cf, ngx_ char * -ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t *keys, ngx_hash_t *types_hash, - ngx_array_t *prev_keys, ngx_hash_t *prev_types_hash, +ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t **keys, ngx_hash_t *types_hash, + ngx_array_t **prev_keys, ngx_hash_t *prev_types_hash, ngx_str_t *default_types) { ngx_hash_init_t hash; - if (keys) { + if (*keys) { + + if (*keys == (void *) -1) { + return NGX_CONF_OK; + } hash.hash = types_hash; hash.key = NULL; @@ -1923,7 +1936,7 @@ ngx_http_merge_types(ngx_conf_t *cf, ngx hash.pool = cf->pool; hash.temp_pool = NULL; - if (ngx_hash_init(&hash, keys->elts, keys->nelts) != NGX_OK) { + if (ngx_hash_init(&hash, (*keys)->elts, (*keys)->nelts) != NGX_OK) { return NGX_CONF_ERROR; } @@ -1932,13 +1945,17 @@ ngx_http_merge_types(ngx_conf_t *cf, ngx if (prev_types_hash->buckets == NULL) { - if (prev_keys == NULL) { + if (*prev_keys == NULL) { - if (ngx_http_set_default_types(cf, &prev_keys, default_types) + if (ngx_http_set_default_types(cf, prev_keys, default_types) != NGX_OK) { return NGX_CONF_ERROR; } + + } else if (*prev_keys == (void *) -1) { + *keys = *prev_keys; + return NGX_CONF_OK; } hash.hash = prev_types_hash; @@ -1949,7 +1966,9 @@ ngx_http_merge_types(ngx_conf_t *cf, ngx hash.pool = cf->pool; hash.temp_pool = NULL; - if (ngx_hash_init(&hash, prev_keys->elts, prev_keys->nelts) != NGX_OK) { + if (ngx_hash_init(&hash, (*prev_keys)->elts, (*prev_keys)->nelts) + != NGX_OK) + { return NGX_CONF_ERROR; } } diff --git a/src/http/ngx_http.h b/src/http/ngx_http.h --- a/src/http/ngx_http.h +++ b/src/http/ngx_http.h @@ -126,9 +126,9 @@ void ngx_http_test_reading(ngx_http_requ char *ngx_http_types_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); -char *ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t *keys, - ngx_hash_t *types_hash, ngx_array_t *prev_keys, ngx_hash_t *prev_types_hash, - ngx_str_t *default_types); +char *ngx_http_merge_types(ngx_conf_t *cf, ngx_array_t **keys, + ngx_hash_t *types_hash, ngx_array_t **prev_keys, + ngx_hash_t *prev_types_hash, ngx_str_t *default_types); ngx_int_t ngx_http_set_default_types(ngx_conf_t *cf, ngx_array_t **types, ngx_str_t *default_type); diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c --- a/src/http/ngx_http_core_module.c +++ b/src/http/ngx_http_core_module.c @@ -1572,6 +1572,10 @@ ngx_http_test_content_type(ngx_http_requ size_t len; ngx_uint_t i, hash; + if (types_hash->size == 0) { + return (void *) 4; + } + if (r->headers_out.content_type.len == 0) { return NULL; }