Mercurial > hg > nginx
comparison src/http/modules/ngx_http_charset_filter.c @ 155:46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 22 Oct 2003 16:38:26 +0000 |
parents | 54307053f185 |
children | 4db54fdbcbe7 |
comparison
equal
deleted
inserted
replaced
154:eac26585476e | 155:46eb23d9471d |
---|---|
48 ngx_http_charset_filter_init, /* init module */ | 48 ngx_http_charset_filter_init, /* init module */ |
49 NULL /* init child */ | 49 NULL /* init child */ |
50 }; | 50 }; |
51 | 51 |
52 | 52 |
53 static int (*next_header_filter) (ngx_http_request_t *r); | 53 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; |
54 #if 0 | 54 #if 0 |
55 static int (*next_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch); | 55 static ngx_http_output_body_filter_pt ngx_http_next_body_filter; |
56 #endif | 56 #endif |
57 | 57 |
58 | 58 |
59 static int ngx_http_charset_header_filter(ngx_http_request_t *r) | 59 static int ngx_http_charset_header_filter(ngx_http_request_t *r) |
60 { | 60 { |
61 ngx_http_charset_loc_conf_t *lcf; | 61 ngx_http_charset_loc_conf_t *lcf; |
62 | 62 |
63 if (r->headers_out.content_type == NULL | 63 if (r->headers_out.content_type == NULL |
64 || ngx_strncasecmp(r->headers_out.content_type->value.data, | 64 || ngx_strncasecmp(r->headers_out.content_type->value.data, |
65 "text/", 5) != 0 | 65 "text/", 5) != 0 |
66 || ngx_strstr(r->headers_out.content_type->value.data, "charset") | 66 || ngx_strstr(r->headers_out.content_type->value.data, "charset") |
67 != NULL | 67 != NULL |
68 ) | 68 ) |
69 { | 69 { |
70 return next_header_filter(r); | 70 return ngx_http_next_header_filter(r); |
71 } | 71 } |
72 | 72 |
73 lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module); | 73 lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module); |
74 | 74 |
75 if (r->headers_out.status == NGX_HTTP_MOVED_PERMANENTLY | 75 if (r->headers_out.status == NGX_HTTP_MOVED_PERMANENTLY |
76 && r->headers_out.status == NGX_HTTP_MOVED_TEMPORARILY) | 76 && r->headers_out.status == NGX_HTTP_MOVED_TEMPORARILY) |
77 { | 77 { |
78 /* do not set charset for the redirect because NN 4.x uses this | 78 |
79 charset instead of the next page charset */ | 79 /* |
80 * do not set charset for the redirect because NN 4.x uses this | |
81 * charset instead of the next page charset | |
82 */ | |
83 | |
80 r->headers_out.charset.len = 0; | 84 r->headers_out.charset.len = 0; |
81 | 85 |
82 } else if (r->headers_out.charset.len == 0) { | 86 } else if (r->headers_out.charset.len == 0) { |
83 r->headers_out.charset = lcf->default_charset; | 87 r->headers_out.charset = lcf->default_charset; |
84 } | 88 } |
85 | 89 |
86 return next_header_filter(r); | 90 return ngx_http_next_header_filter(r); |
87 } | 91 } |
88 | 92 |
89 | 93 |
90 #if 0 | 94 #if 0 |
91 static int ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in) | 95 static int ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in) |
92 { | 96 { |
93 ngx_log_debug(r->connection->log, "CHARSET BODY"); | 97 ngx_log_debug(r->connection->log, "CHARSET BODY"); |
94 return next_body_filter(r, in); | 98 return ngx_http_next_body_filter(r, in); |
95 } | 99 } |
96 #endif | 100 #endif |
97 | 101 |
98 | 102 |
99 static int ngx_http_charset_filter_init(ngx_cycle_t *cycle) | 103 static int ngx_http_charset_filter_init(ngx_cycle_t *cycle) |
100 { | 104 { |
101 next_header_filter = ngx_http_top_header_filter; | 105 ngx_http_next_header_filter = ngx_http_top_header_filter; |
102 ngx_http_top_header_filter = ngx_http_charset_header_filter; | 106 ngx_http_top_header_filter = ngx_http_charset_header_filter; |
103 | 107 |
104 #if 0 | 108 #if 0 |
105 next_body_filter = ngx_http_top_body_filter; | 109 ngx_http_next_body_filter = ngx_http_top_body_filter; |
106 ngx_http_top_body_filter = ngx_http_charset_body_filter; | 110 ngx_http_top_body_filter = ngx_http_charset_body_filter; |
107 #endif | 111 #endif |
108 | 112 |
109 return NGX_OK; | 113 return NGX_OK; |
110 } | 114 } |