Mercurial > hg > nginx-vendor-1-0
comparison src/http/modules/ngx_http_addition_filter_module.c @ 394:05981f639d21 NGINX_0_7_9
nginx 0.7.9
*) Change: now ngx_http_charset_module works by default with following
MIME types: text/html, text/css, text/xml, text/plain,
text/vnd.wap.wml, application/x-javascript, and application/rss+xml.
*) Feature: the "charset_types" and "addition_types" directives.
*) Feature: now the "gzip_types", "ssi_types", and "sub_filter_types"
directives use hash.
*) Feature: the ngx_cpp_test_module.
*) Feature: the "expires" directive supports daily time.
*) Feature: the ngx_http_xslt_module improvements and bug fixing.
Thanks to Denis F. Latypoff and Maxim Dounin.
*) Bugfix: the "log_not_found" directive did not work for index files
tests.
*) Bugfix: HTTPS connections might hang, if kqueue, epoll, rtsig, or
eventport methods were used; the bug had appeared in 0.7.7.
*) Bugfix: if the "server_name", "valid_referers", and "map" directives
used an "*.domain.tld" wildcard and exact name "domain.tld" was not
set, then the exact name was matched by the wildcard; the bugs had
appeared in 0.3.18.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Tue, 12 Aug 2008 00:00:00 +0400 |
parents | 5bef04fc3fd5 |
children | e7dbea1ee115 |
comparison
equal
deleted
inserted
replaced
393:040b8c84d040 | 394:05981f639d21 |
---|---|
8 #include <ngx_core.h> | 8 #include <ngx_core.h> |
9 #include <ngx_http.h> | 9 #include <ngx_http.h> |
10 | 10 |
11 | 11 |
12 typedef struct { | 12 typedef struct { |
13 ngx_str_t before_body; | 13 ngx_str_t before_body; |
14 ngx_str_t after_body; | 14 ngx_str_t after_body; |
15 | |
16 ngx_hash_t types; | |
17 ngx_array_t *types_keys; | |
15 } ngx_http_addition_conf_t; | 18 } ngx_http_addition_conf_t; |
16 | 19 |
17 | 20 |
18 typedef struct { | 21 typedef struct { |
19 ngx_uint_t before_body_sent; | 22 ngx_uint_t before_body_sent; |
20 } ngx_http_addition_ctx_t; | 23 } ngx_http_addition_ctx_t; |
21 | 24 |
22 | 25 |
23 static void *ngx_http_addition_create_conf(ngx_conf_t *cf); | 26 static void *ngx_http_addition_create_conf(ngx_conf_t *cf); |
24 static char *ngx_http_addition_merge_conf(ngx_conf_t *cf, void *parent, | 27 static char *ngx_http_addition_merge_conf(ngx_conf_t *cf, void *parent, |
39 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, | 42 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1, |
40 ngx_conf_set_str_slot, | 43 ngx_conf_set_str_slot, |
41 NGX_HTTP_LOC_CONF_OFFSET, | 44 NGX_HTTP_LOC_CONF_OFFSET, |
42 offsetof(ngx_http_addition_conf_t, after_body), | 45 offsetof(ngx_http_addition_conf_t, after_body), |
43 NULL }, | 46 NULL }, |
47 | |
48 { ngx_string("addtion_types"), | |
49 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_1MORE, | |
50 ngx_http_types_slot, | |
51 NGX_HTTP_LOC_CONF_OFFSET, | |
52 offsetof(ngx_http_addition_conf_t, types_keys), | |
53 &ngx_http_html_default_types[0] }, | |
44 | 54 |
45 ngx_null_command | 55 ngx_null_command |
46 }; | 56 }; |
47 | 57 |
48 | 58 |
85 ngx_http_addition_header_filter(ngx_http_request_t *r) | 95 ngx_http_addition_header_filter(ngx_http_request_t *r) |
86 { | 96 { |
87 ngx_http_addition_ctx_t *ctx; | 97 ngx_http_addition_ctx_t *ctx; |
88 ngx_http_addition_conf_t *conf; | 98 ngx_http_addition_conf_t *conf; |
89 | 99 |
90 if (r->headers_out.status != NGX_HTTP_OK | 100 if (r->headers_out.status != NGX_HTTP_OK || r != r->main) { |
91 || r != r->main | |
92 || r->headers_out.content_type.data == NULL) | |
93 { | |
94 return ngx_http_next_header_filter(r); | 101 return ngx_http_next_header_filter(r); |
95 } | 102 } |
96 | 103 |
97 conf = ngx_http_get_module_loc_conf(r, ngx_http_addition_filter_module); | 104 conf = ngx_http_get_module_loc_conf(r, ngx_http_addition_filter_module); |
98 | 105 |
99 if (conf->before_body.len == 0 && conf->after_body.len == 0) { | 106 if (conf->before_body.len == 0 && conf->after_body.len == 0) { |
100 return ngx_http_next_header_filter(r); | 107 return ngx_http_next_header_filter(r); |
101 } | 108 } |
102 | 109 |
103 if (ngx_strncasecmp(r->headers_out.content_type.data, | 110 if (ngx_http_test_content_type(r, &conf->types) == NULL) { |
104 (u_char *) "text/html", sizeof("text/html") - 1) | |
105 != 0) | |
106 { | |
107 return ngx_http_next_header_filter(r); | 111 return ngx_http_next_header_filter(r); |
108 } | 112 } |
109 | 113 |
110 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_addition_ctx_t)); | 114 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_addition_ctx_t)); |
111 if (ctx == NULL) { | 115 if (ctx == NULL) { |
212 } | 216 } |
213 | 217 |
214 /* | 218 /* |
215 * set by ngx_pcalloc(): | 219 * set by ngx_pcalloc(): |
216 * | 220 * |
217 * conf->before_body.len = 0; | 221 * conf->before_body = { 0, NULL }; |
218 * conf->before_body.date = NULL; | 222 * conf->after_body = { 0, NULL }; |
219 * conf->after_body.len = 0; | 223 * conf->types = { NULL }; |
220 * conf->after_body.date = NULL; | 224 * conf->types_keys = NULL; |
221 */ | 225 */ |
222 | 226 |
223 return conf; | 227 return conf; |
224 } | 228 } |
225 | 229 |
231 ngx_http_addition_conf_t *conf = child; | 235 ngx_http_addition_conf_t *conf = child; |
232 | 236 |
233 ngx_conf_merge_str_value(conf->before_body, prev->before_body, ""); | 237 ngx_conf_merge_str_value(conf->before_body, prev->before_body, ""); |
234 ngx_conf_merge_str_value(conf->after_body, prev->after_body, ""); | 238 ngx_conf_merge_str_value(conf->after_body, prev->after_body, ""); |
235 | 239 |
240 if (ngx_http_merge_types(cf, conf->types_keys, &conf->types, | |
241 prev->types_keys, &prev->types, | |
242 ngx_http_html_default_types) | |
243 != NGX_OK) | |
244 { | |
245 return NGX_CONF_ERROR; | |
246 } | |
247 | |
236 return NGX_CONF_OK; | 248 return NGX_CONF_OK; |
237 } | 249 } |