diff src/http/modules/ngx_http_charset_filter_module.c @ 210:14050d2bec9b NGINX_0_3_52

nginx 0.3.52 *) Change: the ngx_http_index_module behavior for the "POST /" requests is reverted to the 0.3.40 version state: the module now does not return the 405 error. *) Bugfix: the worker process may got caught in an endless loop if the limit rate was used; bug appeared in 0.3.37. *) Bugfix: ngx_http_charset_module logged "unknown charset" alert, even if the recoding was not needed; bug appeared in 0.3.50. *) Bugfix: if a code response of the PUT request was 409, then a temporary file was not removed.
author Igor Sysoev <http://sysoev.ru>
date Mon, 03 Jul 2006 00:00:00 +0400
parents b12b3b1a9426
children 56688ed172c8
line wrap: on
line diff
--- a/src/http/modules/ngx_http_charset_filter_module.c
+++ b/src/http/modules/ngx_http_charset_filter_module.c
@@ -215,7 +215,7 @@ ngx_http_charset_header_filter(ngx_http_
                                         r->headers_out.override_charset->data);
 
             if (charset == NGX_HTTP_NO_CHARSET) {
-                ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
+                ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                               "unknown charset \"%V\" to override",
                               r->headers_out.override_charset);
 
@@ -269,18 +269,8 @@ ngx_http_charset_header_filter(ngx_http_
 
             ctx->charset = charset;
 
-            if (charset == NGX_HTTP_NO_CHARSET) {
-                ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
-                              "unknown charset \"%V\" of main request", mc);
-
-                return ngx_http_next_header_filter(r);
-            }
-        }
-
-        charset = ctx->charset;
-
-        if (charset == NGX_HTTP_NO_CHARSET) {
-            return ngx_http_next_header_filter(r);
+        } else {
+            charset = ctx->charset;
         }
     }
 
@@ -289,16 +279,41 @@ ngx_http_charset_header_filter(ngx_http_
     if (r->headers_out.charset.len == 0) {
         lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module);
 
-        return ngx_http_charset_set_charset(r, mcf->charsets.elts, charset,
-                                            lcf->source_charset);
+        if (charset != NGX_HTTP_NO_CHARSET) {
+            return ngx_http_charset_set_charset(r, mcf->charsets.elts, charset,
+                                                lcf->source_charset);
+        }
+
+        if (lcf->source_charset == NGX_CONF_UNSET) {
+            return ngx_http_next_header_filter(r);
+        }
+
+        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+                      "no \"charset_map\" between the charsets "
+                      "\"%V\" and \"%V\"",
+                      &charsets[lcf->source_charset].name,
+                      &r->main->headers_out.charset);
+
+        return ngx_http_next_header_filter(r);
     }
 
     source_charset = ngx_http_charset_get_charset(charsets, n,
                                                   r->headers_out.charset.data);
 
-    if (source_charset == NGX_HTTP_NO_CHARSET) {
-        ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
-                      "unknown source charset \"%V\"", &r->headers_out.charset);
+    if (charset == NGX_HTTP_NO_CHARSET
+        || source_charset == NGX_HTTP_NO_CHARSET)
+    {
+        if (charset != source_charset
+            || ngx_strcasecmp(r->main->headers_out.charset.data,
+                              r->headers_out.charset.data)
+                != 0)
+        {
+            ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
+                          "no \"charset_map\" between the charsets "
+                          "\"%V\" and \"%V\"",
+                          &r->headers_out.charset,
+                          &r->main->headers_out.charset);
+        }
 
         return ngx_http_next_header_filter(r);
     }
@@ -307,7 +322,7 @@ ngx_http_charset_header_filter(ngx_http_
         && (charsets[source_charset].tables == NULL
             || charsets[source_charset].tables[charset] == NULL))
     {
-        ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
+        ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
                       "no \"charset_map\" between the charsets "
                       "\"%V\" and \"%V\"",
                       &charsets[source_charset].name, &charsets[charset].name);