diff src/http/modules/ngx_http_charset_filter.c @ 26:45fe5b98a9de NGINX_0_1_13

nginx 0.1.13 *) Feature: the server_names_hash and server_names_hash_threshold directives. *) Bugfix: the *.domain.tld names in the "server_name" directive did not work. *) Bugfix: the %request_length log parameter logged the incorrect length.
author Igor Sysoev <http://sysoev.ru>
date Tue, 21 Dec 2004 00:00:00 +0300
parents 46833bd150cb
children 6cfc63e68377
line wrap: on
line diff
--- a/src/http/modules/ngx_http_charset_filter.c
+++ b/src/http/modules/ngx_http_charset_filter.c
@@ -147,12 +147,6 @@ static ngx_int_t ngx_http_charset_header
         return ngx_http_next_header_filter(r);
     }
 
-#if 0
-    if (lcf->default_charset.len == 0) {
-        return ngx_http_next_header_filter(r);
-    }
-#endif
-
     if (r->headers_out.content_type == NULL) {
         return ngx_http_next_header_filter(r);
     }
@@ -559,12 +553,36 @@ static char *ngx_http_charset_merge_loc_
     ngx_conf_merge_value(conf->enable, prev->enable, 0);
     ngx_conf_merge_value(conf->autodetect, prev->autodetect, 0);
 
+
+    if (conf->default_charset == NGX_CONF_UNSET) {
+        conf->default_charset = prev->default_charset;
+    }
+
     if (conf->source_charset == NGX_CONF_UNSET) {
         conf->source_charset = prev->source_charset;
     }
 
-    ngx_conf_merge_value(conf->default_charset, prev->default_charset,
-                         conf->source_charset);
+    if (conf->default_charset == NGX_CONF_UNSET
+        && conf->source_charset != NGX_CONF_UNSET)
+    {
+        conf->default_charset = conf->source_charset;
+    }
+
+    if (conf->source_charset == NGX_CONF_UNSET
+        && conf->default_charset != NGX_CONF_UNSET)
+    {
+        conf->source_charset = conf->default_charset;
+    }
+
+    if (conf->enable
+        && (conf->default_charset == NGX_CONF_UNSET
+            || conf->source_charset == NGX_CONF_UNSET))
+    {
+        ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                           "the \"source_charset\" or \"default_charset\" "
+                           "must be specified when \"charset\" is on");
+        return NGX_CONF_ERROR;
+    }
 
     return NGX_CONF_OK;
 }