diff src/http/modules/ngx_http_charset_filter_module.c @ 202:ca5f86d94316 NGINX_0_3_48

nginx 0.3.48 *) Change: now the ngx_http_charset_module works for subrequests, if the response has no "Content-Type" header line. *) Bugfix: if the "proxy_pass" directive has no URI part, then the "proxy_redirect default" directive add the unnecessary slash in start of the rewritten redirect. *) Bugfix: the internal redirect always transform client's HTTP method to GET, now the transformation is made for the "X-Accel-Redirect" redirects only and if the method is not HEAD; bug appeared in 0.3.42. *) Bugfix: the ngx_http_perl_module could not be built, if the perl was built with the threads support; bug appeared in 0.3.46.
author Igor Sysoev <http://sysoev.ru>
date Mon, 29 May 2006 00:00:00 +0400
parents 71ff1e2b484a
children 3866d57d9cfd
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
@@ -154,7 +154,7 @@ ngx_http_charset_header_filter(ngx_http_
     ngx_uint_t                     i;
     ngx_http_charset_t            *charsets;
     ngx_http_charset_ctx_t        *ctx;
-    ngx_http_charset_loc_conf_t   *lcf;
+    ngx_http_charset_loc_conf_t   *lcf, *mlcf;
     ngx_http_charset_main_conf_t  *mcf;
 
     mcf = ngx_http_get_module_main_conf(r, ngx_http_charset_filter_module);
@@ -162,9 +162,9 @@ ngx_http_charset_header_filter(ngx_http_
     ctx = ngx_http_get_module_ctx(r->main, ngx_http_charset_filter_module);
 
     if (ctx == NULL) {
-        lcf = ngx_http_get_module_loc_conf(r->main,
-                                           ngx_http_charset_filter_module);
-        charset = lcf->charset;
+        mlcf = ngx_http_get_module_loc_conf(r->main,
+                                            ngx_http_charset_filter_module);
+        charset = mlcf->charset;
 
         if (charset == NGX_HTTP_NO_CHARSET) {
             return ngx_http_next_header_filter(r);
@@ -174,19 +174,30 @@ ngx_http_charset_header_filter(ngx_http_
         charset = ctx->charset;
     }
 
-    if (r->headers_out.content_type.len == 0) {
-        return ngx_http_next_header_filter(r);
-    }
+    charsets = mcf->charsets.elts;
+
+    if (r == r->main) {
+        if (r->headers_out.content_type.len == 0) {
+            return ngx_http_next_header_filter(r);
+        }
 
-    if (ngx_strncasecmp(r->headers_out.content_type.data, "text/", 5) != 0
-        && ngx_strncasecmp(r->headers_out.content_type.data,
-                           "application/x-javascript", 24) != 0)
-    {
-        return ngx_http_next_header_filter(r);
+        if (ngx_strncasecmp(r->headers_out.content_type.data, "text/", 5) != 0
+            && ngx_strncasecmp(r->headers_out.content_type.data,
+                               "application/x-javascript", 24) != 0)
+        {
+            return ngx_http_next_header_filter(r);
+        }
+
+    } else {
+        if (r->headers_out.content_type.len == 0) {
+            mlcf = ngx_http_get_module_loc_conf(r->main,
+                                                ngx_http_charset_filter_module);
+            source_charset = mlcf->source_charset;
+
+            goto found;
+        }
     }
 
-    charsets = mcf->charsets.elts;
-
     lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module);
 
     len = 0;