Mercurial > hg > nginx-quic
annotate src/http/modules/ngx_http_charset_filter_module.c @ 2251:91d7a9eb8ade release-0.7.17
nginx-0.7.17-RELEASE
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 15 Sep 2008 16:59:30 +0000 |
parents | 8caf97ecb136 |
children | cc13ff6d5c07 |
rev | line source |
---|---|
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
1 |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
2 /* |
444
42d11f017717
nginx-0.1.0-2004-09-29-20:00:49 import; remove years from copyright
Igor Sysoev <igor@sysoev.ru>
parents:
441
diff
changeset
|
3 * Copyright (C) Igor Sysoev |
441
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
4 */ |
da8c5707af39
nginx-0.1.0-2004-09-28-12:34:51 import; set copyright and remove unused files
Igor Sysoev <igor@sysoev.ru>
parents:
396
diff
changeset
|
5 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
6 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
7 #include <ngx_config.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
8 #include <ngx_core.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
9 #include <ngx_http.h> |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
10 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
11 |
657 | 12 #define NGX_HTTP_NO_CHARSET -2 |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
13 #define NGX_HTTP_CHARSET_VAR 0x10000 |
657 | 14 |
15 /* 1 byte length and up to 3 bytes for the UTF-8 encoding of the UCS-2 */ | |
16 #define NGX_UTF_LEN 4 | |
17 | |
18 #define NGX_HTML_ENTITY_LEN (sizeof("") - 1) | |
529 | 19 |
20 | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
21 typedef struct { |
657 | 22 u_char **tables; |
23 ngx_str_t name; | |
523 | 24 |
657 | 25 unsigned length:16; |
26 unsigned utf8:1; | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
27 } ngx_http_charset_t; |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
28 |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
29 |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
30 typedef struct { |
657 | 31 ngx_int_t src; |
32 ngx_int_t dst; | |
529 | 33 } ngx_http_charset_recode_t; |
34 | |
35 | |
36 typedef struct { | |
657 | 37 ngx_int_t src; |
38 ngx_int_t dst; | |
39 u_char *src2dst; | |
40 u_char *dst2src; | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
41 } ngx_http_charset_tables_t; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
42 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
43 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
44 typedef struct { |
657 | 45 ngx_array_t charsets; /* ngx_http_charset_t */ |
46 ngx_array_t tables; /* ngx_http_charset_tables_t */ | |
47 ngx_array_t recodes; /* ngx_http_charset_recode_t */ | |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
48 } ngx_http_charset_main_conf_t; |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
49 |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
50 |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
51 typedef struct { |
657 | 52 ngx_int_t charset; |
53 ngx_int_t source_charset; | |
54 ngx_flag_t override_charset; | |
2167 | 55 |
56 ngx_hash_t types; | |
57 ngx_array_t *types_keys; | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
58 } ngx_http_charset_loc_conf_t; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
59 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
60 |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
61 typedef struct { |
657 | 62 u_char *table; |
63 ngx_int_t charset; | |
64 | |
65 ngx_chain_t *busy; | |
66 ngx_chain_t *free_bufs; | |
67 ngx_chain_t *free_buffers; | |
68 | |
69 size_t saved_len; | |
70 u_char saved[NGX_UTF_LEN]; | |
71 | |
72 unsigned length:16; | |
73 unsigned from_utf8:1; | |
74 unsigned to_utf8:1; | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
75 } ngx_http_charset_ctx_t; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
76 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
77 |
657 | 78 typedef struct { |
79 ngx_http_charset_tables_t *table; | |
80 ngx_http_charset_t *charset; | |
81 ngx_uint_t characters; | |
82 } ngx_http_charset_conf_ctx_t; | |
83 | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
84 |
657 | 85 static ngx_int_t ngx_http_charset_get_charset(ngx_http_charset_t *charsets, |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
86 ngx_uint_t n, ngx_str_t *charset); |
657 | 87 static ngx_int_t ngx_http_charset_set_charset(ngx_http_request_t *r, |
88 ngx_http_charset_t *charsets, ngx_int_t charset, ngx_int_t source_charset); | |
89 static ngx_uint_t ngx_http_charset_recode(ngx_buf_t *b, u_char *table); | |
90 static ngx_chain_t *ngx_http_charset_recode_from_utf8(ngx_pool_t *pool, | |
91 ngx_buf_t *buf, ngx_http_charset_ctx_t *ctx); | |
92 static ngx_chain_t *ngx_http_charset_recode_to_utf8(ngx_pool_t *pool, | |
93 ngx_buf_t *buf, ngx_http_charset_ctx_t *ctx); | |
94 | |
95 static ngx_chain_t *ngx_http_charset_get_buf(ngx_pool_t *pool, | |
96 ngx_http_charset_ctx_t *ctx); | |
97 static ngx_chain_t *ngx_http_charset_get_buffer(ngx_pool_t *pool, | |
98 ngx_http_charset_ctx_t *ctx, size_t size); | |
99 | |
100 static char *ngx_http_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd, | |
501 | 101 void *conf); |
657 | 102 static char *ngx_http_charset_map(ngx_conf_t *cf, ngx_command_t *dummy, |
103 void *conf); | |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
104 |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
105 static char *ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd, |
501 | 106 void *conf); |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
107 static ngx_int_t ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name); |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
108 |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
109 static void *ngx_http_charset_create_main_conf(ngx_conf_t *cf); |
119
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
110 static void *ngx_http_charset_create_loc_conf(ngx_conf_t *cf); |
cd54bcbaf3b5
nginx-0.0.1-2003-07-21-01:15:59 import
Igor Sysoev <igor@sysoev.ru>
parents:
113
diff
changeset
|
111 static char *ngx_http_charset_merge_loc_conf(ngx_conf_t *cf, |
501 | 112 void *parent, void *child); |
529 | 113 static ngx_int_t ngx_http_charset_postconfiguration(ngx_conf_t *cf); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
114 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
115 |
2167 | 116 ngx_str_t ngx_http_charset_default_types[] = { |
117 ngx_string("text/html"), | |
118 ngx_string("text/xml"), | |
119 ngx_string("text/plain"), | |
120 ngx_string("text/vnd.wap.wml"), | |
121 ngx_string("application/x-javascript"), | |
122 ngx_string("application/rss+xml"), | |
123 ngx_null_string | |
124 }; | |
125 | |
126 | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
127 static ngx_command_t ngx_http_charset_filter_commands[] = { |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
128 |
529 | 129 { ngx_string("charset"), |
559 | 130 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF |
131 |NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1, | |
529 | 132 ngx_http_set_charset_slot, |
133 NGX_HTTP_LOC_CONF_OFFSET, | |
134 offsetof(ngx_http_charset_loc_conf_t, charset), | |
135 NULL }, | |
136 | |
137 { ngx_string("source_charset"), | |
559 | 138 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF |
139 |NGX_HTTP_LIF_CONF|NGX_CONF_TAKE1, | |
529 | 140 ngx_http_set_charset_slot, |
141 NGX_HTTP_LOC_CONF_OFFSET, | |
142 offsetof(ngx_http_charset_loc_conf_t, source_charset), | |
143 NULL }, | |
144 | |
635 | 145 { ngx_string("override_charset"), |
146 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF | |
147 |NGX_HTTP_LIF_CONF|NGX_CONF_FLAG, | |
148 ngx_conf_set_flag_slot, | |
149 NGX_HTTP_LOC_CONF_OFFSET, | |
150 offsetof(ngx_http_charset_loc_conf_t, override_charset), | |
151 NULL }, | |
152 | |
2167 | 153 { ngx_string("charset_types"), |
154 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
155 ngx_http_types_slot, | |
156 NGX_HTTP_LOC_CONF_OFFSET, | |
157 offsetof(ngx_http_charset_loc_conf_t, types_keys), | |
158 &ngx_http_charset_default_types[0] }, | |
159 | |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
160 { ngx_string("charset_map"), |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
161 NGX_HTTP_MAIN_CONF|NGX_CONF_BLOCK|NGX_CONF_TAKE2, |
657 | 162 ngx_http_charset_map_block, |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
163 NGX_HTTP_MAIN_CONF_OFFSET, |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
164 0, |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
165 NULL }, |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
166 |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
167 ngx_null_command |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
168 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
169 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
170 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
171 static ngx_http_module_t ngx_http_charset_filter_module_ctx = { |
509 | 172 NULL, /* preconfiguration */ |
529 | 173 ngx_http_charset_postconfiguration, /* postconfiguration */ |
177
4db54fdbcbe7
nginx-0.0.1-2003-11-10-20:17:31 import
Igor Sysoev <igor@sysoev.ru>
parents:
155
diff
changeset
|
174 |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
175 ngx_http_charset_create_main_conf, /* create main configuration */ |
529 | 176 NULL, /* init main configuration */ |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
177 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
178 NULL, /* create server configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
179 NULL, /* merge server configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
180 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
181 ngx_http_charset_create_loc_conf, /* create location configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
182 ngx_http_charset_merge_loc_conf /* merge location configuration */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
183 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
184 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
185 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
186 ngx_module_t ngx_http_charset_filter_module = { |
509 | 187 NGX_MODULE_V1, |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
188 &ngx_http_charset_filter_module_ctx, /* module context */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
189 ngx_http_charset_filter_commands, /* module directives */ |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
190 NGX_HTTP_MODULE, /* module type */ |
541 | 191 NULL, /* init master */ |
681 | 192 NULL, /* init module */ |
541 | 193 NULL, /* init process */ |
194 NULL, /* init thread */ | |
195 NULL, /* exit thread */ | |
196 NULL, /* exit process */ | |
197 NULL, /* exit master */ | |
198 NGX_MODULE_V1_PADDING | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
199 }; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
200 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
201 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
139
diff
changeset
|
202 static ngx_http_output_header_filter_pt ngx_http_next_header_filter; |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
139
diff
changeset
|
203 static ngx_http_output_body_filter_pt ngx_http_next_body_filter; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
204 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
205 |
501 | 206 static ngx_int_t |
207 ngx_http_charset_header_filter(ngx_http_request_t *r) | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
208 { |
635 | 209 ngx_int_t charset, source_charset; |
1310
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
210 ngx_str_t *mc, *from, *to, s; |
657 | 211 ngx_uint_t n; |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
212 ngx_http_charset_t *charsets; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
213 ngx_http_charset_ctx_t *ctx; |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
214 ngx_http_variable_value_t *vv; |
653 | 215 ngx_http_charset_loc_conf_t *lcf, *mlcf; |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
216 ngx_http_charset_main_conf_t *mcf; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
217 |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
218 mcf = ngx_http_get_module_main_conf(r, ngx_http_charset_filter_module); |
635 | 219 |
657 | 220 charsets = mcf->charsets.elts; |
221 n = mcf->charsets.nelts; | |
635 | 222 |
657 | 223 /* destination charset */ |
653 | 224 |
225 if (r == r->main) { | |
657 | 226 |
2050
c0bafb136d7b
disable charset if there is "Content-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
1944
diff
changeset
|
227 if (r->headers_out.content_encoding |
c0bafb136d7b
disable charset if there is "Content-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
1944
diff
changeset
|
228 && r->headers_out.content_encoding->value.len) |
c0bafb136d7b
disable charset if there is "Content-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
1944
diff
changeset
|
229 { |
c0bafb136d7b
disable charset if there is "Content-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
1944
diff
changeset
|
230 return ngx_http_next_header_filter(r); |
c0bafb136d7b
disable charset if there is "Content-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
1944
diff
changeset
|
231 } |
c0bafb136d7b
disable charset if there is "Content-Encoding" header
Igor Sysoev <igor@sysoev.ru>
parents:
1944
diff
changeset
|
232 |
653 | 233 if (r->headers_out.content_type.len == 0) { |
234 return ngx_http_next_header_filter(r); | |
235 } | |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
236 |
657 | 237 if (r->headers_out.override_charset |
238 && r->headers_out.override_charset->len) | |
653 | 239 { |
657 | 240 charset = ngx_http_charset_get_charset(charsets, n, |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
241 r->headers_out.override_charset); |
657 | 242 |
243 if (charset == NGX_HTTP_NO_CHARSET) { | |
661 | 244 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, |
657 | 245 "unknown charset \"%V\" to override", |
659 | 246 r->headers_out.override_charset); |
657 | 247 |
248 return ngx_http_next_header_filter(r); | |
249 } | |
250 | |
251 } else { | |
252 mlcf = ngx_http_get_module_loc_conf(r, | |
253 ngx_http_charset_filter_module); | |
254 charset = mlcf->charset; | |
255 | |
256 if (charset == NGX_HTTP_NO_CHARSET) { | |
257 return ngx_http_next_header_filter(r); | |
258 } | |
259 | |
260 if (r->headers_out.charset.len) { | |
261 if (mlcf->override_charset == 0) { | |
262 return ngx_http_next_header_filter(r); | |
263 } | |
264 | |
265 } else { | |
2167 | 266 if (ngx_http_test_content_type(r, &mlcf->types) == NULL) { |
657 | 267 return ngx_http_next_header_filter(r); |
268 } | |
269 } | |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
270 |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
271 if (charset >= NGX_HTTP_CHARSET_VAR) { |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
272 vv = ngx_http_get_indexed_variable(r, |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
273 charset - NGX_HTTP_CHARSET_VAR); |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
274 |
797
36f7b549f481
fix segfault if $server_addr failed
Igor Sysoev <igor@sysoev.ru>
parents:
752
diff
changeset
|
275 if (vv == NULL || vv->not_found) { |
36f7b549f481
fix segfault if $server_addr failed
Igor Sysoev <igor@sysoev.ru>
parents:
752
diff
changeset
|
276 return NGX_ERROR; |
36f7b549f481
fix segfault if $server_addr failed
Igor Sysoev <igor@sysoev.ru>
parents:
752
diff
changeset
|
277 } |
36f7b549f481
fix segfault if $server_addr failed
Igor Sysoev <igor@sysoev.ru>
parents:
752
diff
changeset
|
278 |
1310
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
279 s.len = vv->len; |
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
280 s.data = vv->data; |
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
281 |
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
282 charset = ngx_http_charset_get_charset(charsets, n, &s); |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
283 } |
653 | 284 } |
285 | |
286 } else { | |
657 | 287 ctx = ngx_http_get_module_ctx(r->main, ngx_http_charset_filter_module); |
288 | |
289 if (ctx == NULL) { | |
290 | |
291 mc = &r->main->headers_out.charset; | |
292 | |
293 if (mc->len == 0) { | |
294 return ngx_http_next_header_filter(r); | |
295 } | |
296 | |
297 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_charset_ctx_t)); | |
298 if (ctx == NULL) { | |
299 return NGX_ERROR; | |
300 } | |
301 | |
302 ngx_http_set_ctx(r->main, ctx, ngx_http_charset_filter_module); | |
653 | 303 |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
304 charset = ngx_http_charset_get_charset(charsets, n, mc); |
657 | 305 |
306 ctx->charset = charset; | |
307 | |
661 | 308 } else { |
309 charset = ctx->charset; | |
653 | 310 } |
389
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
311 } |
537de4dca8ca
nginx-0.0.7-2004-07-13-21:59:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
356
diff
changeset
|
312 |
657 | 313 /* source charset */ |
635 | 314 |
657 | 315 if (r->headers_out.charset.len == 0) { |
316 lcf = ngx_http_get_module_loc_conf(r, ngx_http_charset_filter_module); | |
635 | 317 |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
318 source_charset = lcf->source_charset; |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
319 |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
320 if (source_charset >= NGX_HTTP_CHARSET_VAR) { |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
321 vv = ngx_http_get_indexed_variable(r, |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
322 source_charset - NGX_HTTP_CHARSET_VAR); |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
323 |
797
36f7b549f481
fix segfault if $server_addr failed
Igor Sysoev <igor@sysoev.ru>
parents:
752
diff
changeset
|
324 if (vv == NULL || vv->not_found) { |
36f7b549f481
fix segfault if $server_addr failed
Igor Sysoev <igor@sysoev.ru>
parents:
752
diff
changeset
|
325 return NGX_ERROR; |
36f7b549f481
fix segfault if $server_addr failed
Igor Sysoev <igor@sysoev.ru>
parents:
752
diff
changeset
|
326 } |
36f7b549f481
fix segfault if $server_addr failed
Igor Sysoev <igor@sysoev.ru>
parents:
752
diff
changeset
|
327 |
1310
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
328 s.len = vv->len; |
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
329 s.data = vv->data; |
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
330 |
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
331 source_charset = ngx_http_charset_get_charset(charsets, n, &s); |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
332 } |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
333 |
661 | 334 if (charset != NGX_HTTP_NO_CHARSET) { |
335 return ngx_http_charset_set_charset(r, mcf->charsets.elts, charset, | |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
336 source_charset); |
661 | 337 } |
338 | |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
339 if (source_charset == NGX_CONF_UNSET) { |
661 | 340 return ngx_http_next_header_filter(r); |
341 } | |
342 | |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
343 from = &charsets[source_charset].name; |
663 | 344 to = &r->main->headers_out.charset; |
661 | 345 |
663 | 346 goto no_charset_map; |
657 | 347 } |
635 | 348 |
657 | 349 source_charset = ngx_http_charset_get_charset(charsets, n, |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
350 &r->headers_out.charset); |
635 | 351 |
661 | 352 if (charset == NGX_HTTP_NO_CHARSET |
353 || source_charset == NGX_HTTP_NO_CHARSET) | |
354 { | |
355 if (charset != source_charset | |
356 || ngx_strcasecmp(r->main->headers_out.charset.data, | |
357 r->headers_out.charset.data) | |
358 != 0) | |
359 { | |
663 | 360 from = &r->headers_out.charset; |
361 to = (charset == NGX_HTTP_NO_CHARSET) ? | |
362 &r->main->headers_out.charset: | |
363 &charsets[charset].name; | |
364 | |
365 goto no_charset_map; | |
661 | 366 } |
635 | 367 |
657 | 368 return ngx_http_next_header_filter(r); |
369 } | |
635 | 370 |
657 | 371 if (source_charset != charset |
372 && (charsets[source_charset].tables == NULL | |
373 || charsets[source_charset].tables[charset] == NULL)) | |
374 { | |
663 | 375 from = &charsets[source_charset].name; |
376 to = &charsets[charset].name; | |
635 | 377 |
663 | 378 goto no_charset_map; |
133
b27548f540ad
nginx-0.0.1-2003-09-24-23:51:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
379 } |
b27548f540ad
nginx-0.0.1-2003-09-24-23:51:12 import
Igor Sysoev <igor@sysoev.ru>
parents:
119
diff
changeset
|
380 |
657 | 381 r->headers_out.content_type.len = r->headers_out.content_type_len; |
382 | |
383 return ngx_http_charset_set_charset(r, mcf->charsets.elts, charset, | |
384 source_charset); | |
663 | 385 |
386 no_charset_map: | |
387 | |
388 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
1587 | 389 "no \"charset_map\" between the charsets \"%V\" and \"%V\"", |
1589 | 390 from, to); |
663 | 391 |
392 return ngx_http_next_header_filter(r); | |
657 | 393 } |
394 | |
395 | |
396 static ngx_int_t | |
397 ngx_http_charset_get_charset(ngx_http_charset_t *charsets, ngx_uint_t n, | |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
398 ngx_str_t *charset) |
657 | 399 { |
400 ngx_uint_t i; | |
401 | |
402 for (i = 0; i < n; i++) { | |
1310
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
403 if (charsets[i].name.len != charset->len) { |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
404 continue; |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
405 } |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
406 |
1310
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
407 if (ngx_strncasecmp(charsets[i].name.data, charset->data, charset->len) |
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
408 == 0) |
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1107
diff
changeset
|
409 { |
657 | 410 return i; |
411 } | |
412 } | |
413 | |
414 return NGX_HTTP_NO_CHARSET; | |
415 } | |
416 | |
417 | |
418 static ngx_int_t | |
419 ngx_http_charset_set_charset(ngx_http_request_t *r, | |
420 ngx_http_charset_t *charsets, ngx_int_t charset, ngx_int_t source_charset) | |
421 { | |
422 ngx_http_charset_ctx_t *ctx; | |
423 | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
424 if (r->headers_out.status == NGX_HTTP_MOVED_PERMANENTLY |
501 | 425 || r->headers_out.status == NGX_HTTP_MOVED_TEMPORARILY) |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
426 { |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
139
diff
changeset
|
427 /* |
635 | 428 * do not set charset for the redirect because NN 4.x |
429 * use this charset instead of the next page charset | |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
139
diff
changeset
|
430 */ |
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
139
diff
changeset
|
431 |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
432 r->headers_out.charset.len = 0; |
657 | 433 |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
434 return ngx_http_next_header_filter(r); |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
435 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
436 |
635 | 437 r->headers_out.charset = charsets[charset].name; |
438 r->utf8 = charsets[charset].utf8; | |
439 | |
440 if (source_charset == NGX_CONF_UNSET || source_charset == charset) { | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
441 return ngx_http_next_header_filter(r); |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
442 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
443 |
501 | 444 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_charset_ctx_t)); |
445 if (ctx == NULL) { | |
446 return NGX_ERROR; | |
447 } | |
448 | |
449 ngx_http_set_ctx(r, ctx, ngx_http_charset_filter_module); | |
450 | |
635 | 451 ctx->table = charsets[source_charset].tables[charset]; |
452 ctx->charset = charset; | |
657 | 453 ctx->length = charsets[charset].length; |
454 ctx->from_utf8 = charsets[source_charset].utf8; | |
455 ctx->to_utf8 = charsets[charset].utf8; | |
456 | |
663 | 457 r->filter_need_in_memory = 1; |
458 | |
657 | 459 if ((ctx->to_utf8 || ctx->from_utf8) && r == r->main) { |
460 ngx_http_clear_content_length(r); | |
663 | 461 |
462 } else { | |
463 r->filter_need_temporary = 1; | |
657 | 464 } |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
465 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
139
diff
changeset
|
466 return ngx_http_next_header_filter(r); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
467 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
468 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
469 |
501 | 470 static ngx_int_t |
471 ngx_http_charset_body_filter(ngx_http_request_t *r, ngx_chain_t *in) | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
472 { |
657 | 473 ngx_int_t rc; |
474 ngx_buf_t *b; | |
475 ngx_chain_t *cl, *out, **ll; | |
635 | 476 ngx_http_charset_ctx_t *ctx; |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
477 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
478 ctx = ngx_http_get_module_ctx(r, ngx_http_charset_filter_module); |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
479 |
635 | 480 if (ctx == NULL || ctx->table == NULL) { |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
481 return ngx_http_next_body_filter(r, in); |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
482 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
483 |
657 | 484 if ((ctx->to_utf8 || ctx->from_utf8) || ctx->busy) { |
485 | |
486 out = NULL; | |
487 ll = &out; | |
488 | |
489 for (cl = in; cl; cl = cl->next) { | |
490 b = cl->buf; | |
491 | |
492 if (ngx_buf_size(b) == 0) { | |
665 | 493 |
494 *ll = ngx_alloc_chain_link(r->pool); | |
495 if (*ll == NULL) { | |
496 return NGX_ERROR; | |
497 } | |
498 | |
499 (*ll)->buf = b; | |
500 (*ll)->next = NULL; | |
501 | |
502 ll = &(*ll)->next; | |
503 | |
657 | 504 continue; |
505 } | |
506 | |
507 if (ctx->to_utf8) { | |
508 *ll = ngx_http_charset_recode_to_utf8(r->pool, b, ctx); | |
509 | |
510 } else { | |
511 *ll = ngx_http_charset_recode_from_utf8(r->pool, b, ctx); | |
512 } | |
513 | |
514 if (*ll == NULL) { | |
515 return NGX_ERROR; | |
516 } | |
517 | |
518 while (*ll) { | |
519 ll = &(*ll)->next; | |
520 } | |
521 } | |
522 | |
523 rc = ngx_http_next_body_filter(r, out); | |
524 | |
525 if (out) { | |
526 if (ctx->busy == NULL) { | |
527 ctx->busy = out; | |
528 | |
529 } else { | |
530 for (cl = ctx->busy; cl->next; cl = cl->next) { /* void */ } | |
531 cl->next = out; | |
532 } | |
533 } | |
534 | |
535 while (ctx->busy) { | |
536 | |
537 cl = ctx->busy; | |
538 b = cl->buf; | |
539 | |
540 if (ngx_buf_size(b) != 0) { | |
541 break; | |
542 } | |
543 | |
544 #if (NGX_HAVE_WRITE_ZEROCOPY) | |
545 if (b->zerocopy_busy) { | |
546 break; | |
547 } | |
548 #endif | |
549 | |
550 ctx->busy = cl->next; | |
551 | |
552 if (b->tag != (ngx_buf_tag_t) &ngx_http_charset_filter_module) { | |
553 continue; | |
554 } | |
555 | |
556 if (b->shadow) { | |
557 b->shadow->pos = b->shadow->last; | |
558 } | |
559 | |
560 if (b->pos) { | |
561 cl->next = ctx->free_buffers; | |
562 ctx->free_buffers = cl; | |
563 continue; | |
564 } | |
565 | |
566 cl->next = ctx->free_bufs; | |
567 ctx->free_bufs = cl; | |
568 } | |
569 | |
570 return rc; | |
571 } | |
572 | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
573 for (cl = in; cl; cl = cl->next) { |
635 | 574 (void) ngx_http_charset_recode(cl->buf, ctx->table); |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
575 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
576 |
155
46eb23d9471d
nginx-0.0.1-2003-10-22-20:38:26 import
Igor Sysoev <igor@sysoev.ru>
parents:
139
diff
changeset
|
577 return ngx_http_next_body_filter(r, in); |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
578 } |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
579 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
580 |
501 | 581 static ngx_uint_t |
635 | 582 ngx_http_charset_recode(ngx_buf_t *b, u_char *table) |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
583 { |
1944
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
584 u_char *p, *last; |
635 | 585 |
1944
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
586 last = b->last; |
455 | 587 |
1944
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
588 for (p = b->pos; p < last; p++) { |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
589 |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
590 if (*p != table[*p]) { |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
591 goto recode; |
455 | 592 } |
593 } | |
594 | |
635 | 595 return 0; |
1944
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
596 |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
597 recode: |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
598 |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
599 do { |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
600 if (*p != table[*p]) { |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
601 *p = table[*p]; |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
602 } |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
603 |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
604 p++; |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
605 |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
606 } while (p < last); |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
607 |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
608 b->in_file = 0; |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
609 |
be6c9033a798
speed up ngx_http_charset_recode() for 25%: google-perftools reported
Igor Sysoev <igor@sysoev.ru>
parents:
1590
diff
changeset
|
610 return 1; |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
611 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
612 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
613 |
657 | 614 static ngx_chain_t * |
615 ngx_http_charset_recode_from_utf8(ngx_pool_t *pool, ngx_buf_t *buf, | |
616 ngx_http_charset_ctx_t *ctx) | |
617 { | |
618 size_t len, size; | |
619 u_char c, *p, *src, *dst, *saved, **table; | |
620 uint32_t n; | |
621 ngx_buf_t *b; | |
622 ngx_uint_t i; | |
623 ngx_chain_t *out, *cl, **ll; | |
624 | |
625 src = buf->pos; | |
626 | |
627 if (ctx->saved_len == 0) { | |
628 | |
629 for ( /* void */ ; src < buf->last; src++) { | |
630 | |
631 if (*src < 0x80) { | |
632 continue; | |
633 } | |
634 | |
635 len = src - buf->pos; | |
636 | |
637 if (len > 512) { | |
638 out = ngx_http_charset_get_buf(pool, ctx); | |
639 if (out == NULL) { | |
640 return NULL; | |
641 } | |
642 | |
643 b = out->buf; | |
644 | |
645 b->temporary = buf->temporary; | |
646 b->memory = buf->memory; | |
647 b->mmap = buf->mmap; | |
648 b->flush = buf->flush; | |
649 | |
650 b->pos = buf->pos; | |
651 b->last = src; | |
652 | |
653 out->buf = b; | |
654 out->next = NULL; | |
655 | |
656 size = buf->last - src; | |
657 | |
658 saved = src; | |
2125
8e4b9d2acde8
rename ngx_utf_...() to ngx_utf8_...()
Igor Sysoev <igor@sysoev.ru>
parents:
2050
diff
changeset
|
659 n = ngx_utf8_decode(&saved, size); |
657 | 660 |
661 if (n == 0xfffffffe) { | |
662 /* incomplete UTF-8 symbol */ | |
663 | |
664 ngx_memcpy(ctx->saved, src, size); | |
665 ctx->saved_len = size; | |
666 | |
667 b->shadow = buf; | |
668 | |
669 return out; | |
670 } | |
671 | |
672 } else { | |
673 out = NULL; | |
674 size = len + buf->last - src; | |
675 src = buf->pos; | |
676 } | |
677 | |
678 if (size < NGX_HTML_ENTITY_LEN) { | |
679 size += NGX_HTML_ENTITY_LEN; | |
680 } | |
681 | |
682 cl = ngx_http_charset_get_buffer(pool, ctx, size); | |
683 if (cl == NULL) { | |
684 return NULL; | |
685 } | |
686 | |
687 if (out) { | |
688 out->next = cl; | |
689 | |
690 } else { | |
691 out = cl; | |
692 } | |
693 | |
694 b = cl->buf; | |
695 dst = b->pos; | |
696 | |
697 goto recode; | |
698 } | |
699 | |
700 out = ngx_alloc_chain_link(pool); | |
701 if (out == NULL) { | |
702 return NULL; | |
703 } | |
704 | |
705 out->buf = buf; | |
706 out->next = NULL; | |
707 | |
708 return out; | |
709 } | |
710 | |
711 /* process incomplete UTF sequence from previous buffer */ | |
712 | |
713 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, pool->log, 0, | |
714 "http charset utf saved: %z", ctx->saved_len); | |
715 | |
716 p = src; | |
717 | |
718 for (i = ctx->saved_len; i < NGX_UTF_LEN; i++) { | |
719 ctx->saved[i] = *p++; | |
720 | |
721 if (p == buf->last) { | |
722 break; | |
723 } | |
724 } | |
725 | |
726 saved = ctx->saved; | |
2125
8e4b9d2acde8
rename ngx_utf_...() to ngx_utf8_...()
Igor Sysoev <igor@sysoev.ru>
parents:
2050
diff
changeset
|
727 n = ngx_utf8_decode(&saved, i); |
657 | 728 |
729 c = '\0'; | |
730 | |
731 if (n < 0x10000) { | |
732 table = (u_char **) ctx->table; | |
733 p = table[n >> 8]; | |
734 | |
735 if (p) { | |
736 c = p[n & 0xff]; | |
737 } | |
738 | |
739 } else if (n == 0xfffffffe) { | |
740 | |
741 /* incomplete UTF-8 symbol */ | |
742 | |
743 if (i < NGX_UTF_LEN) { | |
744 out = ngx_http_charset_get_buf(pool, ctx); | |
745 if (out == NULL) { | |
746 return NULL; | |
747 } | |
748 | |
749 b = out->buf; | |
750 | |
751 b->pos = buf->pos; | |
752 b->last = buf->last; | |
753 b->sync = 1; | |
754 b->shadow = buf; | |
755 | |
756 ngx_memcpy(&ctx->saved[ctx->saved_len], src, i); | |
757 ctx->saved_len += i; | |
758 | |
759 return out; | |
760 } | |
761 } | |
762 | |
763 size = buf->last - buf->pos; | |
764 | |
765 if (size < NGX_HTML_ENTITY_LEN) { | |
766 size += NGX_HTML_ENTITY_LEN; | |
767 } | |
768 | |
769 cl = ngx_http_charset_get_buffer(pool, ctx, size); | |
770 if (cl == NULL) { | |
771 return NULL; | |
772 } | |
773 | |
774 out = cl; | |
775 | |
776 b = cl->buf; | |
777 dst = b->pos; | |
778 | |
779 if (c) { | |
780 *dst++ = c; | |
781 | |
782 } else if (n == 0xfffffffe) { | |
783 *dst++ = '?'; | |
784 | |
785 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pool->log, 0, | |
786 "http charset invalid utf 0"); | |
787 | |
788 saved = &ctx->saved[NGX_UTF_LEN]; | |
789 | |
790 } else if (n > 0x10ffff) { | |
791 *dst++ = '?'; | |
792 | |
793 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pool->log, 0, | |
794 "http charset invalid utf 1"); | |
795 | |
796 } else { | |
797 dst = ngx_sprintf(dst, "&#%uD;", n); | |
798 } | |
799 | |
800 src += (saved - ctx->saved) - ctx->saved_len; | |
801 ctx->saved_len = 0; | |
802 | |
803 recode: | |
804 | |
805 ll = &cl->next; | |
806 | |
807 table = (u_char **) ctx->table; | |
808 | |
809 while (src < buf->last) { | |
810 | |
811 if ((size_t) (b->end - dst) < NGX_HTML_ENTITY_LEN) { | |
812 b->last = dst; | |
813 | |
814 size = buf->last - src + NGX_HTML_ENTITY_LEN; | |
815 | |
816 cl = ngx_http_charset_get_buffer(pool, ctx, size); | |
817 if (cl == NULL) { | |
818 return NULL; | |
819 } | |
820 | |
821 *ll = cl; | |
822 ll = &cl->next; | |
823 | |
824 b = cl->buf; | |
825 dst = b->pos; | |
826 } | |
827 | |
828 if (*src < 0x80) { | |
829 *dst++ = *src++; | |
830 continue; | |
831 } | |
832 | |
833 len = buf->last - src; | |
834 | |
2125
8e4b9d2acde8
rename ngx_utf_...() to ngx_utf8_...()
Igor Sysoev <igor@sysoev.ru>
parents:
2050
diff
changeset
|
835 n = ngx_utf8_decode(&src, len); |
657 | 836 |
837 if (n < 0x10000) { | |
838 | |
839 p = table[n >> 8]; | |
840 | |
841 if (p) { | |
842 c = p[n & 0xff]; | |
843 | |
844 if (c) { | |
845 *dst++ = c; | |
846 continue; | |
847 } | |
848 } | |
849 | |
850 dst = ngx_sprintf(dst, "&#%uD;", n); | |
851 | |
852 continue; | |
853 } | |
854 | |
855 if (n == 0xfffffffe) { | |
856 /* incomplete UTF-8 symbol */ | |
857 | |
858 ngx_memcpy(ctx->saved, src, len); | |
859 ctx->saved_len = len; | |
860 | |
861 if (b->pos == dst) { | |
862 b->sync = 1; | |
863 b->temporary = 0; | |
864 } | |
865 | |
866 break; | |
867 } | |
868 | |
869 if (n > 0x10ffff) { | |
870 *dst++ = '?'; | |
871 | |
872 ngx_log_debug0(NGX_LOG_DEBUG_HTTP, pool->log, 0, | |
873 "http charset invalid utf 2"); | |
874 | |
875 continue; | |
876 } | |
877 | |
878 /* n > 0xffff */ | |
879 | |
880 dst = ngx_sprintf(dst, "&#%uD;", n); | |
881 } | |
882 | |
883 b->last = dst; | |
884 | |
885 b->last_buf = buf->last_buf; | |
886 b->last_in_chain = buf->last_in_chain; | |
887 b->flush = buf->flush; | |
888 | |
889 b->shadow = buf; | |
890 | |
891 return out; | |
892 } | |
893 | |
894 | |
895 static ngx_chain_t * | |
896 ngx_http_charset_recode_to_utf8(ngx_pool_t *pool, ngx_buf_t *buf, | |
897 ngx_http_charset_ctx_t *ctx) | |
898 { | |
899 size_t len, size; | |
900 u_char *p, *src, *dst, *table; | |
901 ngx_buf_t *b; | |
902 ngx_chain_t *out, *cl, **ll; | |
903 | |
904 table = ctx->table; | |
905 | |
906 for (src = buf->pos; src < buf->last; src++) { | |
907 if (table[*src * NGX_UTF_LEN] == '\1') { | |
908 continue; | |
909 } | |
910 | |
911 goto recode; | |
912 } | |
913 | |
914 out = ngx_alloc_chain_link(pool); | |
915 if (out == NULL) { | |
916 return NULL; | |
917 } | |
918 | |
919 out->buf = buf; | |
920 out->next = NULL; | |
921 | |
922 return out; | |
923 | |
924 recode: | |
925 | |
926 /* | |
927 * we assume that there are about half of characters to be recoded, | |
928 * so we preallocate "size / 2 + size / 2 * ctx->length" | |
929 */ | |
930 | |
931 len = src - buf->pos; | |
932 | |
933 if (len > 512) { | |
934 out = ngx_http_charset_get_buf(pool, ctx); | |
935 if (out == NULL) { | |
936 return NULL; | |
937 } | |
938 | |
939 b = out->buf; | |
940 | |
941 b->temporary = buf->temporary; | |
942 b->memory = buf->memory; | |
943 b->mmap = buf->mmap; | |
944 b->flush = buf->flush; | |
945 | |
946 b->pos = buf->pos; | |
947 b->last = src; | |
948 | |
949 out->buf = b; | |
950 out->next = NULL; | |
951 | |
952 size = buf->last - src; | |
953 size = size / 2 + size / 2 * ctx->length; | |
954 | |
955 } else { | |
956 out = NULL; | |
957 | |
958 size = buf->last - src; | |
959 size = len + size / 2 + size / 2 * ctx->length; | |
960 | |
961 src = buf->pos; | |
962 } | |
963 | |
964 cl = ngx_http_charset_get_buffer(pool, ctx, size); | |
965 if (cl == NULL) { | |
966 return NULL; | |
967 } | |
968 | |
969 if (out) { | |
970 out->next = cl; | |
971 | |
972 } else { | |
973 out = cl; | |
974 } | |
975 | |
976 ll = &cl->next; | |
977 | |
978 b = cl->buf; | |
979 dst = b->pos; | |
980 | |
981 while (src < buf->last) { | |
982 | |
983 p = &table[*src++ * NGX_UTF_LEN]; | |
984 len = *p++; | |
985 | |
986 if ((size_t) (b->end - dst) < len) { | |
987 b->last = dst; | |
988 | |
989 size = buf->last - src; | |
990 size = len + size / 2 + size / 2 * ctx->length; | |
991 | |
992 cl = ngx_http_charset_get_buffer(pool, ctx, size); | |
993 if (cl == NULL) { | |
994 return NULL; | |
995 } | |
996 | |
997 *ll = cl; | |
998 ll = &cl->next; | |
999 | |
1000 b = cl->buf; | |
1001 dst = b->pos; | |
1002 } | |
1003 | |
1004 while (len) { | |
1005 *dst++ = *p++; | |
1006 len--; | |
1007 } | |
1008 } | |
1009 | |
1010 b->last = dst; | |
1011 | |
1012 b->last_buf = buf->last_buf; | |
1013 b->last_in_chain = buf->last_in_chain; | |
1014 b->flush = buf->flush; | |
1015 | |
1016 b->shadow = buf; | |
1017 | |
1018 return out; | |
1019 } | |
1020 | |
1021 | |
1022 static ngx_chain_t * | |
1023 ngx_http_charset_get_buf(ngx_pool_t *pool, ngx_http_charset_ctx_t *ctx) | |
1024 { | |
1025 ngx_chain_t *cl; | |
1026 | |
1027 cl = ctx->free_bufs; | |
1028 | |
1029 if (cl) { | |
1030 ctx->free_bufs = cl->next; | |
1031 | |
1032 cl->buf->shadow = NULL; | |
1033 cl->next = NULL; | |
1034 | |
1035 return cl; | |
1036 } | |
1037 | |
1038 cl = ngx_alloc_chain_link(pool); | |
1039 if (cl == NULL) { | |
1040 return NULL; | |
1041 } | |
1042 | |
1043 cl->buf = ngx_calloc_buf(pool); | |
1044 if (cl->buf == NULL) { | |
1045 return NULL; | |
1046 } | |
1047 | |
1048 cl->next = NULL; | |
1049 | |
1050 cl->buf->tag = (ngx_buf_tag_t) &ngx_http_charset_filter_module; | |
1051 | |
1052 return cl; | |
1053 } | |
1054 | |
1055 | |
1056 static ngx_chain_t * | |
1057 ngx_http_charset_get_buffer(ngx_pool_t *pool, ngx_http_charset_ctx_t *ctx, | |
1058 size_t size) | |
1059 { | |
1060 ngx_buf_t *b; | |
1061 ngx_chain_t *cl, **ll; | |
1062 | |
1063 for (ll = &ctx->free_buffers, cl = ctx->free_buffers; | |
1064 cl; | |
1065 ll = &cl->next, cl = cl->next) | |
1066 { | |
1067 b = cl->buf; | |
1068 | |
1069 if ((size_t) (b->end - b->start) >= size) { | |
1070 *ll = cl->next; | |
1071 cl->next = NULL; | |
1072 | |
1073 b->pos = b->start; | |
1074 b->temporary = 1; | |
1075 b->shadow = NULL; | |
1076 | |
1077 return cl; | |
1078 } | |
1079 } | |
1080 | |
1081 cl = ngx_alloc_chain_link(pool); | |
1082 if (cl == NULL) { | |
1083 return NULL; | |
1084 } | |
1085 | |
1086 cl->buf = ngx_create_temp_buf(pool, size); | |
1087 if (cl->buf == NULL) { | |
1088 return NULL; | |
1089 } | |
1090 | |
1091 cl->next = NULL; | |
1092 | |
1093 cl->buf->temporary = 1; | |
1094 cl->buf->tag = (ngx_buf_tag_t) &ngx_http_charset_filter_module; | |
1095 | |
1096 return cl; | |
1097 } | |
1098 | |
1099 | |
501 | 1100 static char * |
657 | 1101 ngx_http_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1102 { |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1103 ngx_http_charset_main_conf_t *mcf = conf; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1104 |
657 | 1105 char *rv; |
1106 u_char *p, *dst2src, **pp; | |
1107 ngx_int_t src, dst; | |
1108 ngx_uint_t i, n; | |
1109 ngx_str_t *value; | |
1110 ngx_conf_t pvcf; | |
1111 ngx_http_charset_t *charset; | |
1112 ngx_http_charset_tables_t *table; | |
1113 ngx_http_charset_conf_ctx_t ctx; | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1114 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1115 value = cf->args->elts; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1116 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1117 src = ngx_http_add_charset(&mcf->charsets, &value[1]); |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1118 if (src == NGX_ERROR) { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1119 return NGX_CONF_ERROR; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1120 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1121 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1122 dst = ngx_http_add_charset(&mcf->charsets, &value[2]); |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1123 if (dst == NGX_ERROR) { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1124 return NGX_CONF_ERROR; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1125 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1126 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1127 if (src == dst) { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1128 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1129 "\"charset_map\" between the same charsets " |
461 | 1130 "\"%V\" and \"%V\"", &value[1], &value[2]); |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1131 return NGX_CONF_ERROR; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1132 } |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1133 |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1134 table = mcf->tables.elts; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1135 for (i = 0; i < mcf->tables.nelts; i++) { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1136 if ((src == table->src && dst == table->dst) |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1137 || (src == table->dst && dst == table->src)) |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1138 { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1139 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1140 "duplicate \"charset_map\" between " |
461 | 1141 "\"%V\" and \"%V\"", &value[1], &value[2]); |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1142 return NGX_CONF_ERROR; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1143 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1144 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1145 |
501 | 1146 table = ngx_array_push(&mcf->tables); |
1147 if (table == NULL) { | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1148 return NGX_CONF_ERROR; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1149 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1150 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1151 table->src = src; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1152 table->dst = dst; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1153 |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
797
diff
changeset
|
1154 if (ngx_strcasecmp(value[2].data, (u_char *) "utf-8") == 0) { |
657 | 1155 table->src2dst = ngx_pcalloc(cf->pool, 256 * NGX_UTF_LEN); |
1156 if (table->src2dst == NULL) { | |
1157 return NGX_CONF_ERROR; | |
1158 } | |
1159 | |
1160 table->dst2src = ngx_pcalloc(cf->pool, 256 * sizeof(void *)); | |
1161 if (table->dst2src == NULL) { | |
1162 return NGX_CONF_ERROR; | |
1163 } | |
1164 | |
1165 dst2src = ngx_pcalloc(cf->pool, 256); | |
1166 if (dst2src == NULL) { | |
1167 return NGX_CONF_ERROR; | |
1168 } | |
1169 | |
1170 pp = (u_char **) &table->dst2src[0]; | |
1171 pp[0] = dst2src; | |
1172 | |
1173 for (i = 0; i < 128; i++) { | |
1174 p = &table->src2dst[i * NGX_UTF_LEN]; | |
1175 p[0] = '\1'; | |
1176 p[1] = (u_char) i; | |
1177 dst2src[i] = (u_char) i; | |
1178 } | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1179 |
657 | 1180 for (/* void */; i < 256; i++) { |
1181 p = &table->src2dst[i * NGX_UTF_LEN]; | |
1182 p[0] = '\1'; | |
1183 p[1] = '?'; | |
1184 } | |
1185 | |
1186 } else { | |
1187 table->src2dst = ngx_palloc(cf->pool, 256); | |
1188 if (table->src2dst == NULL) { | |
1189 return NGX_CONF_ERROR; | |
1190 } | |
1191 | |
1192 table->dst2src = ngx_palloc(cf->pool, 256); | |
1193 if (table->dst2src == NULL) { | |
1194 return NGX_CONF_ERROR; | |
1195 } | |
1196 | |
1197 for (i = 0; i < 128; i++) { | |
1198 table->src2dst[i] = (u_char) i; | |
1199 table->dst2src[i] = (u_char) i; | |
1200 } | |
1201 | |
1202 for (/* void */; i < 256; i++) { | |
1203 table->src2dst[i] = '?'; | |
1204 table->dst2src[i] = '?'; | |
1205 } | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1206 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1207 |
657 | 1208 charset = mcf->charsets.elts; |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1209 |
657 | 1210 ctx.table = table; |
1211 ctx.charset = &charset[dst]; | |
1212 ctx.characters = 0; | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1213 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1214 pvcf = *cf; |
657 | 1215 cf->ctx = &ctx; |
1216 cf->handler = ngx_http_charset_map; | |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1217 cf->handler_conf = conf; |
501 | 1218 |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1219 rv = ngx_conf_parse(cf, NULL); |
501 | 1220 |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1221 *cf = pvcf; |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1222 |
657 | 1223 if (ctx.characters) { |
1224 n = ctx.charset->length; | |
1225 ctx.charset->length /= ctx.characters; | |
1226 | |
1227 if (((n * 10) / ctx.characters) % 10 > 4) { | |
1228 ctx.charset->length++; | |
1229 } | |
1230 } | |
1231 | |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1232 return rv; |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1233 } |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1234 |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1235 |
501 | 1236 static char * |
657 | 1237 ngx_http_charset_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf) |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1238 { |
657 | 1239 u_char *p, *dst2src, **pp; |
1240 uint32_t n; | |
1241 ngx_int_t src, dst; | |
1242 ngx_str_t *value; | |
1243 ngx_uint_t i; | |
1244 ngx_http_charset_tables_t *table; | |
1245 ngx_http_charset_conf_ctx_t *ctx; | |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1246 |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1247 if (cf->args->nelts != 2) { |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1248 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "invalid parameters number"); |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1249 return NGX_CONF_ERROR; |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1250 } |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1251 |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1252 value = cf->args->elts; |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1253 |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1254 src = ngx_hextoi(value[0].data, value[0].len); |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1255 if (src == NGX_ERROR || src > 255) { |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1256 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
461 | 1257 "invalid value \"%V\"", &value[0]); |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1258 return NGX_CONF_ERROR; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1259 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1260 |
657 | 1261 ctx = cf->ctx; |
1262 table = ctx->table; | |
1263 | |
1264 if (ctx->charset->utf8) { | |
1265 p = &table->src2dst[src * NGX_UTF_LEN]; | |
1266 | |
1267 *p++ = (u_char) (value[1].len / 2); | |
1268 | |
1269 for (i = 0; i < value[1].len; i += 2) { | |
1270 dst = ngx_hextoi(&value[1].data[i], 2); | |
1271 if (dst == NGX_ERROR || dst > 255) { | |
1272 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1273 "invalid value \"%V\"", &value[1]); | |
1274 return NGX_CONF_ERROR; | |
1275 } | |
1276 | |
1277 *p++ = (u_char) dst; | |
1278 } | |
1279 | |
1280 i /= 2; | |
1281 | |
1282 ctx->charset->length += i; | |
1283 ctx->characters++; | |
1284 | |
1285 p = &table->src2dst[src * NGX_UTF_LEN] + 1; | |
1286 | |
2125
8e4b9d2acde8
rename ngx_utf_...() to ngx_utf8_...()
Igor Sysoev <igor@sysoev.ru>
parents:
2050
diff
changeset
|
1287 n = ngx_utf8_decode(&p, i); |
657 | 1288 |
1289 if (n > 0xffff) { | |
1290 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1291 "invalid value \"%V\"", &value[1]); | |
1292 return NGX_CONF_ERROR; | |
1293 } | |
1294 | |
1295 pp = (u_char **) &table->dst2src[0]; | |
1296 | |
1297 dst2src = pp[n >> 8]; | |
1298 | |
1299 if (dst2src == NULL) { | |
1300 dst2src = ngx_pcalloc(cf->pool, 256); | |
1301 if (dst2src == NULL) { | |
1302 return NGX_CONF_ERROR; | |
1303 } | |
1304 | |
1305 pp[n >> 8] = dst2src; | |
1306 } | |
1307 | |
1308 dst2src[n & 0xff] = (u_char) src; | |
1309 | |
1310 } else { | |
1311 dst = ngx_hextoi(value[1].data, value[1].len); | |
1312 if (dst == NGX_ERROR || dst > 255) { | |
1313 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
1314 "invalid value \"%V\"", &value[1]); | |
1315 return NGX_CONF_ERROR; | |
1316 } | |
1317 | |
1318 table->src2dst[src] = (u_char) dst; | |
1319 table->dst2src[dst] = (u_char) src; | |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1320 } |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1321 |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1322 return NGX_CONF_OK; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1323 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1324 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1325 |
501 | 1326 static char * |
1327 ngx_http_set_charset_slot(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1328 { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1329 char *p = conf; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1330 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1331 ngx_int_t *cp; |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1332 ngx_str_t *value, var; |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1333 ngx_http_charset_main_conf_t *mcf; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1334 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1335 cp = (ngx_int_t *) (p + cmd->offset); |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1336 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1337 if (*cp != NGX_CONF_UNSET) { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1338 return "is duplicate"; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1339 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1340 |
529 | 1341 value = cf->args->elts; |
1342 | |
1343 if (cmd->offset == offsetof(ngx_http_charset_loc_conf_t, charset) | |
1344 && ngx_strcmp(value[1].data, "off") == 0) | |
1345 { | |
1346 *cp = NGX_HTTP_NO_CHARSET; | |
1347 return NGX_CONF_OK; | |
1348 } | |
1349 | |
752
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1350 |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1351 if (value[1].data[0] == '$') { |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1352 var.len = value[1].len - 1; |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1353 var.data = value[1].data + 1; |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1354 |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1355 *cp = ngx_http_get_variable_index(cf, &var); |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1356 |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1357 if (*cp == NGX_ERROR) { |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1358 return NGX_CONF_ERROR; |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1359 } |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1360 |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1361 *cp += NGX_HTTP_CHARSET_VAR; |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1362 |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1363 return NGX_CONF_OK; |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1364 } |
907361d07f25
ngx_http_charset_module supports the variables
Igor Sysoev <igor@sysoev.ru>
parents:
681
diff
changeset
|
1365 |
396
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
1366 mcf = ngx_http_conf_get_module_main_conf(cf, |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
1367 ngx_http_charset_filter_module); |
6f3b20c1ac50
nginx-0.0.7-2004-07-18-23:11:20 import
Igor Sysoev <igor@sysoev.ru>
parents:
389
diff
changeset
|
1368 |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1369 *cp = ngx_http_add_charset(&mcf->charsets, &value[1]); |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1370 if (*cp == NGX_ERROR) { |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1371 return NGX_CONF_ERROR; |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1372 } |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1373 |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1374 return NGX_CONF_OK; |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1375 } |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1376 |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1377 |
501 | 1378 static ngx_int_t |
1379 ngx_http_add_charset(ngx_array_t *charsets, ngx_str_t *name) | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1380 { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1381 ngx_uint_t i; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1382 ngx_http_charset_t *c; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1383 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1384 c = charsets->elts; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1385 for (i = 0; i < charsets->nelts; i++) { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1386 if (name->len != c[i].name.len) { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1387 continue; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1388 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1389 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1390 if (ngx_strcasecmp(name->data, c[i].name.data) == 0) { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1391 break; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1392 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1393 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1394 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1395 if (i < charsets->nelts) { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1396 return i; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1397 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1398 |
501 | 1399 c = ngx_array_push(charsets); |
1400 if (c == NULL) { | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1401 return NGX_ERROR; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1402 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1403 |
455 | 1404 c->tables = NULL; |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1405 c->name = *name; |
657 | 1406 c->length = 0; |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1407 |
1107
db7c468c447d
ngx_strcasecmp()/ngx_strncasecmp()
Igor Sysoev <igor@sysoev.ru>
parents:
797
diff
changeset
|
1408 if (ngx_strcasecmp(name->data, (u_char *) "utf-8") == 0) { |
523 | 1409 c->utf8 = 1; |
667 | 1410 |
1411 } else { | |
1412 c->utf8 = 0; | |
523 | 1413 } |
1414 | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1415 return i; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1416 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1417 |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1418 |
501 | 1419 static void * |
1420 ngx_http_charset_create_main_conf(ngx_conf_t *cf) | |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1421 { |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1422 ngx_http_charset_main_conf_t *mcf; |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1423 |
501 | 1424 mcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_charset_main_conf_t)); |
1425 if (mcf == NULL) { | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1426 return NGX_CONF_ERROR; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1427 } |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1428 |
501 | 1429 if (ngx_array_init(&mcf->charsets, cf->pool, 2, sizeof(ngx_http_charset_t)) |
529 | 1430 == NGX_ERROR) |
501 | 1431 { |
1432 return NGX_CONF_ERROR; | |
1433 } | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1434 |
529 | 1435 if (ngx_array_init(&mcf->tables, cf->pool, 1, |
501 | 1436 sizeof(ngx_http_charset_tables_t)) == NGX_ERROR) |
1437 { | |
1438 return NGX_CONF_ERROR; | |
1439 } | |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1440 |
529 | 1441 if (ngx_array_init(&mcf->recodes, cf->pool, 2, |
1442 sizeof(ngx_http_charset_recode_t)) == NGX_ERROR) | |
1443 { | |
1444 return NGX_CONF_ERROR; | |
1445 } | |
1446 | |
338
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1447 return mcf; |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1448 } |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1449 |
0376cffa29e6
nginx-0.0.3-2004-05-20-21:33:52 import
Igor Sysoev <igor@sysoev.ru>
parents:
307
diff
changeset
|
1450 |
501 | 1451 static void * |
1452 ngx_http_charset_create_loc_conf(ngx_conf_t *cf) | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1453 { |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1454 ngx_http_charset_loc_conf_t *lcf; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1455 |
501 | 1456 lcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_charset_loc_conf_t)); |
1457 if (lcf == NULL) { | |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1458 return NGX_CONF_ERROR; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1459 } |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1460 |
2167 | 1461 /* |
1462 * set by ngx_pcalloc(): | |
1463 * | |
1464 * lcf->types = { NULL }; | |
1465 * lcf->types_keys = NULL; | |
1466 */ | |
1467 | |
529 | 1468 lcf->charset = NGX_CONF_UNSET; |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1469 lcf->source_charset = NGX_CONF_UNSET; |
635 | 1470 lcf->override_charset = NGX_CONF_UNSET; |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1471 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1472 return lcf; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1473 } |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1474 |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1475 |
501 | 1476 static char * |
1477 ngx_http_charset_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1478 { |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1479 ngx_http_charset_loc_conf_t *prev = parent; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1480 ngx_http_charset_loc_conf_t *conf = child; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1481 |
529 | 1482 ngx_uint_t i; |
1483 ngx_http_charset_recode_t *recode; | |
1484 ngx_http_charset_main_conf_t *mcf; | |
477 | 1485 |
2175
a69886fc2864
*) fix segfaults in types hash
Igor Sysoev <igor@sysoev.ru>
parents:
2167
diff
changeset
|
1486 if (ngx_http_merge_types(cf, conf->types_keys, &conf->types, |
a69886fc2864
*) fix segfaults in types hash
Igor Sysoev <igor@sysoev.ru>
parents:
2167
diff
changeset
|
1487 prev->types_keys, &prev->types, |
a69886fc2864
*) fix segfaults in types hash
Igor Sysoev <igor@sysoev.ru>
parents:
2167
diff
changeset
|
1488 ngx_http_charset_default_types) |
a69886fc2864
*) fix segfaults in types hash
Igor Sysoev <igor@sysoev.ru>
parents:
2167
diff
changeset
|
1489 != NGX_OK) |
a69886fc2864
*) fix segfaults in types hash
Igor Sysoev <igor@sysoev.ru>
parents:
2167
diff
changeset
|
1490 { |
a69886fc2864
*) fix segfaults in types hash
Igor Sysoev <igor@sysoev.ru>
parents:
2167
diff
changeset
|
1491 return NGX_CONF_ERROR; |
a69886fc2864
*) fix segfaults in types hash
Igor Sysoev <igor@sysoev.ru>
parents:
2167
diff
changeset
|
1492 } |
a69886fc2864
*) fix segfaults in types hash
Igor Sysoev <igor@sysoev.ru>
parents:
2167
diff
changeset
|
1493 |
635 | 1494 ngx_conf_merge_value(conf->override_charset, prev->override_charset, 0); |
529 | 1495 ngx_conf_merge_value(conf->charset, prev->charset, NGX_HTTP_NO_CHARSET); |
477 | 1496 |
339
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1497 if (conf->source_charset == NGX_CONF_UNSET) { |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1498 conf->source_charset = prev->source_charset; |
8c5b69141dfd
nginx-0.0.3-2004-05-21-20:12:13 import
Igor Sysoev <igor@sysoev.ru>
parents:
338
diff
changeset
|
1499 } |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1500 |
529 | 1501 if (conf->charset == NGX_HTTP_NO_CHARSET |
1502 || conf->source_charset == NGX_CONF_UNSET | |
1503 || conf->charset == conf->source_charset) | |
477 | 1504 { |
529 | 1505 return NGX_CONF_OK; |
477 | 1506 } |
1507 | |
1590 | 1508 if (conf->source_charset >= NGX_HTTP_CHARSET_VAR |
1509 || conf->charset >= NGX_HTTP_CHARSET_VAR) | |
1510 { | |
1511 return NGX_CONF_OK; | |
1512 } | |
1513 | |
529 | 1514 mcf = ngx_http_conf_get_module_main_conf(cf, |
1515 ngx_http_charset_filter_module); | |
1516 recode = mcf->recodes.elts; | |
1517 for (i = 0; i < mcf->recodes.nelts; i++) { | |
1518 if (conf->source_charset == recode[i].src | |
1519 && conf->charset == recode[i].dst) | |
1520 { | |
1521 return NGX_CONF_OK; | |
1522 } | |
477 | 1523 } |
1524 | |
529 | 1525 recode = ngx_array_push(&mcf->recodes); |
1526 if (recode == NULL) { | |
477 | 1527 return NGX_CONF_ERROR; |
1528 } | |
340
0bf903191ceb
nginx-0.0.3-2004-05-25-19:28:46 import
Igor Sysoev <igor@sysoev.ru>
parents:
339
diff
changeset
|
1529 |
529 | 1530 recode->src = conf->source_charset; |
1531 recode->dst = conf->charset; | |
1532 | |
99
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1533 return NGX_CONF_OK; |
a059e1aa65d4
nginx-0.0.1-2003-06-02-19:24:30 import
Igor Sysoev <igor@sysoev.ru>
parents:
diff
changeset
|
1534 } |
529 | 1535 |
1536 | |
1537 static ngx_int_t | |
1538 ngx_http_charset_postconfiguration(ngx_conf_t *cf) | |
1539 { | |
635 | 1540 u_char **src, **dst; |
529 | 1541 ngx_int_t c; |
1542 ngx_uint_t i, t; | |
1543 ngx_http_charset_t *charset; | |
1544 ngx_http_charset_recode_t *recode; | |
1545 ngx_http_charset_tables_t *tables; | |
1546 ngx_http_charset_main_conf_t *mcf; | |
1547 | |
1548 mcf = ngx_http_conf_get_module_main_conf(cf, | |
1549 ngx_http_charset_filter_module); | |
1550 | |
1551 recode = mcf->recodes.elts; | |
1552 tables = mcf->tables.elts; | |
1553 charset = mcf->charsets.elts; | |
1554 | |
1555 for (i = 0; i < mcf->recodes.nelts; i++) { | |
1556 | |
1557 c = recode[i].src; | |
1558 | |
1559 for (t = 0; t < mcf->tables.nelts; t++) { | |
1560 | |
1561 if (c == tables[t].src && recode[i].dst == tables[t].dst) { | |
1562 goto next; | |
1563 } | |
1564 | |
1565 if (c == tables[t].dst && recode[i].dst == tables[t].src) { | |
1566 goto next; | |
1567 } | |
1568 } | |
1569 | |
1570 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | |
1588 | 1571 "no \"charset_map\" between the charsets \"%V\" and \"%V\"", |
1572 &charset[c].name, &charset[recode[i].dst].name); | |
529 | 1573 return NGX_ERROR; |
1574 | |
1575 next: | |
1576 continue; | |
1577 } | |
1578 | |
635 | 1579 |
1580 for (t = 0; t < mcf->tables.nelts; t++) { | |
1581 | |
1582 src = charset[tables[t].src].tables; | |
1583 | |
1584 if (src == NULL) { | |
1585 src = ngx_pcalloc(cf->pool, sizeof(u_char *) * mcf->charsets.nelts); | |
1586 if (src == NULL) { | |
1587 return NGX_ERROR; | |
1588 } | |
1589 | |
1590 charset[tables[t].src].tables = src; | |
1591 } | |
1592 | |
1593 dst = charset[tables[t].dst].tables; | |
1594 | |
1595 if (dst == NULL) { | |
1596 dst = ngx_pcalloc(cf->pool, sizeof(u_char *) * mcf->charsets.nelts); | |
1597 if (dst == NULL) { | |
1598 return NGX_ERROR; | |
1599 } | |
1600 | |
1601 charset[tables[t].dst].tables = dst; | |
1602 } | |
1603 | |
1604 src[tables[t].dst] = tables[t].src2dst; | |
1605 dst[tables[t].src] = tables[t].dst2src; | |
1606 } | |
1607 | |
681 | 1608 ngx_http_next_header_filter = ngx_http_top_header_filter; |
1609 ngx_http_top_header_filter = ngx_http_charset_header_filter; | |
1610 | |
1611 ngx_http_next_body_filter = ngx_http_top_body_filter; | |
1612 ngx_http_top_body_filter = ngx_http_charset_body_filter; | |
1613 | |
529 | 1614 return NGX_OK; |
1615 } |