diff src/http/modules/ngx_http_charset_filter_module.c @ 72:b31656313b59 NGINX_0_1_36

nginx 0.1.36 *) Change: if the request header has duplicate the "Host", "Connection", "Content-Length", or "Authorization" lines, then nginx now returns the 400 error. *) Change: the "post_accept_timeout" directive was canceled. *) Feature: the "default", "af=", "bl=", "deferred", and "bind" parameters of the "listen" directive. *) Feature: the FreeBSD accept filters support. *) Feature: the Linux TCP_DEFER_ACCEPT support. *) Bugfix: the ngx_http_autoindex_module did not support the file names in UTF-8. *) Bugfix: the new log file can be rotated by the -USR1 signal only if the reconfiguration by the -HUP signal was made twice.
author Igor Sysoev <http://sysoev.ru>
date Wed, 15 Jun 2005 00:00:00 +0400
parents b55cbf18157e
children 77969b24f355
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
@@ -12,15 +12,17 @@
 typedef struct {
     char       **tables;
     ngx_str_t    name;
-    ngx_uint_t   server;  /* unsigned     server:1; */
+
+    unsigned     server:1;
+    unsigned     utf8:1;
 } ngx_http_charset_t;
 
 
 typedef struct {
-    ngx_int_t   src;
-    ngx_int_t   dst;
-    char       *src2dst;
-    char       *dst2src;
+    ngx_int_t    src;
+    ngx_int_t    dst;
+    char        *src2dst;
+    char        *dst2src;
 } ngx_http_charset_tables_t;
 
 
@@ -31,17 +33,17 @@ typedef struct {
 
 
 typedef struct {
-    ngx_flag_t  enable;
-    ngx_flag_t  autodetect;
+    ngx_flag_t   enable;
+    ngx_flag_t   autodetect;
 
-    ngx_int_t   default_charset;
-    ngx_int_t   source_charset;
+    ngx_int_t    default_charset;
+    ngx_int_t    source_charset;
 } ngx_http_charset_loc_conf_t;
 
 
 typedef struct {
-    ngx_int_t   server;
-    ngx_int_t   client;
+    ngx_int_t    server;
+    ngx_int_t    client;
 } ngx_http_charset_ctx_t;
 
 
@@ -183,6 +185,7 @@ ngx_http_charset_header_filter(ngx_http_
 
     charsets = mcf->charsets.elts;
     r->headers_out.charset = charsets[lcf->default_charset].name;
+    r->utf8 = charsets[lcf->default_charset].utf8;
 
     if (lcf->default_charset == lcf->source_charset) {
         return ngx_http_next_header_filter(r);
@@ -448,6 +451,10 @@ ngx_http_add_charset(ngx_array_t *charse
     c->name = *name;
     c->server = 0;
 
+    if (ngx_strcasecmp(name->data, "utf-8") == 0) {
+        c->utf8 = 1;
+    }
+
     return i;
 }