comparison src/http/modules/ngx_http_charset_filter.c @ 4:4b2dafa26fe2 NGINX_0_1_2

nginx 0.1.2 *) Feature: the --user=USER, --group=GROUP, and --with-ld-opt=OPTIONS options in configure. *) Feature: the server_name directive supports *.domain.tld. *) Bugfix: the portability improvements. *) Bugfix: if configuration file was set in command line, the reconfiguration was impossible; bug appeared in 0.1.1. *) Bugfix: proxy module may get caught in an endless loop when sendfile is not used. *) Bugfix: with sendfile the response was not recoded according to the charset module directives; bug appeared in 0.1.1. *) Bugfix: very seldom bug in the kqueue processing. *) Bugfix: the gzip module compressed the proxied responses that was already compressed.
author Igor Sysoev <http://sysoev.ru>
date Thu, 21 Oct 2004 00:00:00 +0400
parents f0b350454894
children 46833bd150cb
comparison
equal deleted inserted replaced
3:8beaf7b3241f 4:4b2dafa26fe2
10 10
11 11
12 typedef struct { 12 typedef struct {
13 char **tables; 13 char **tables;
14 ngx_str_t name; 14 ngx_str_t name;
15 unsigned server; 15 ngx_uint_t server; /* unsigned server:1; */
16 } ngx_http_charset_t; 16 } ngx_http_charset_t;
17 17
18 18
19 typedef struct { 19 typedef struct {
20 ngx_int_t src; 20 ngx_int_t src;
43 ngx_int_t server; 43 ngx_int_t server;
44 ngx_int_t client; 44 ngx_int_t client;
45 } ngx_http_charset_ctx_t; 45 } ngx_http_charset_ctx_t;
46 46
47 47
48 static void ngx_charset_recode(ngx_buf_t *b, char *table); 48 static ngx_uint_t ngx_charset_recode(ngx_buf_t *b, char *table);
49 49
50 static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd, 50 static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd,
51 void *conf); 51 void *conf);
52 static char *ngx_charset_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf); 52 static char *ngx_charset_map(ngx_conf_t *cf, ngx_command_t *dummy, void *conf);
53 53
230 230
231 return ngx_http_next_body_filter(r, in); 231 return ngx_http_next_body_filter(r, in);
232 } 232 }
233 233
234 234
235 static void ngx_charset_recode(ngx_buf_t *b, char *table) 235 static ngx_uint_t ngx_charset_recode(ngx_buf_t *b, char *table)
236 { 236 {
237 u_char *p, c; 237 u_char *p;
238 ngx_uint_t change;
239
240 change = 0;
238 241
239 for (p = b->pos; p < b->last; p++) { 242 for (p = b->pos; p < b->last; p++) {
240 c = *p; 243 if (*p != table[*p]) {
241 *p = table[c]; 244 change = 1;
242 } 245 break;
246 }
247 }
248
249 if (change) {
250
251 while (p < b->last) {
252 *p = table[*p];
253 p++;
254 }
255
256 b->in_file = 0;
257 }
258
259 return change;
243 } 260 }
244 261
245 262
246 static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd, 263 static char *ngx_charset_map_block(ngx_conf_t *cf, ngx_command_t *cmd,
247 void *conf) 264 void *conf)
417 434
418 if (!(c = ngx_push_array(charsets))) { 435 if (!(c = ngx_push_array(charsets))) {
419 return NGX_ERROR; 436 return NGX_ERROR;
420 } 437 }
421 438
439 c->tables = NULL;
422 c->name = *name; 440 c->name = *name;
441 c->server = 0;
423 442
424 return i; 443 return i;
425 } 444 }
426 445
427 446