annotate src/http/modules/ngx_http_addition_filter_module.c @ 230:38e7b94d63ac NGINX_0_4_0

nginx 0.4.0 *) Change in internal API: the HTTP modules initialization was moved from the init module phase to the HTTP postconfiguration phase. *) Change: now the request body is not read beforehand for the ngx_http_perl_module: it's required to start the reading using the $r->has_request_body method. *) Feature: the ngx_http_perl_module supports the DECLINED return code. *) Feature: the ngx_http_dav_module supports the incoming "Date" header line for the PUT method. *) Feature: the "ssi" directive is available inside the "if" block. *) Bugfix: a segmentation fault occurred if there was an "index" directive with variables and the first index name was without variables; bug appeared in 0.1.29.
author Igor Sysoev <http://sysoev.ru>
date Wed, 30 Aug 2006 00:00:00 +0400
parents fa32d59d9a15
children 500a3242dff6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
2 /*
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
4 */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
5
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
6
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
9 #include <ngx_http.h>
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
10
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
11
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
12 typedef struct {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
13 ngx_str_t before_body;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
14 ngx_str_t after_body;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
15 } ngx_http_addition_conf_t;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
16
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
17
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
18 typedef struct {
180
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
19 ngx_uint_t before_body_sent;
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
20 } ngx_http_addition_ctx_t;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
21
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
22
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
23 static void *ngx_http_addition_create_conf(ngx_conf_t *cf);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
24 static char *ngx_http_addition_merge_conf(ngx_conf_t *cf, void *parent,
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
25 void *child);
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
26 static ngx_int_t ngx_http_addition_filter_init(ngx_conf_t *cf);
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
27
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
28
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
29 static ngx_command_t ngx_http_addition_commands[] = {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
30
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
31 { ngx_string("add_before_body"),
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
32 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
33 ngx_conf_set_str_slot,
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
34 NGX_HTTP_LOC_CONF_OFFSET,
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
35 offsetof(ngx_http_addition_conf_t, before_body),
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
36 NULL },
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
37
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
38 { ngx_string("add_after_body"),
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
39 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
40 ngx_conf_set_str_slot,
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
41 NGX_HTTP_LOC_CONF_OFFSET,
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
42 offsetof(ngx_http_addition_conf_t, after_body),
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
43 NULL },
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
44
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
45 ngx_null_command
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
46 };
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
47
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
48
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
49 static ngx_http_module_t ngx_http_addition_filter_module_ctx = {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
50 NULL, /* preconfiguration */
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
51 ngx_http_addition_filter_init, /* postconfiguration */
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
52
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
53 NULL, /* create main configuration */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
54 NULL, /* init main configuration */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
55
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
56 NULL, /* create server configuration */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
57 NULL, /* merge server configuration */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
58
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
59 ngx_http_addition_create_conf, /* create location configuration */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
60 ngx_http_addition_merge_conf /* merge location configuration */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
61 };
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
62
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
63
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
64 ngx_module_t ngx_http_addition_filter_module = {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
65 NGX_MODULE_V1,
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
66 &ngx_http_addition_filter_module_ctx, /* module context */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
67 ngx_http_addition_commands, /* module directives */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
68 NGX_HTTP_MODULE, /* module type */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
69 NULL, /* init master */
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
70 NULL, /* init module */
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
71 NULL, /* init process */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
72 NULL, /* init thread */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
73 NULL, /* exit thread */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
74 NULL, /* exit process */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
75 NULL, /* exit master */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
76 NGX_MODULE_V1_PADDING
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
77 };
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
78
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
79
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
80 static ngx_http_output_header_filter_pt ngx_http_next_header_filter;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
81 static ngx_http_output_body_filter_pt ngx_http_next_body_filter;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
82
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
83
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
84 static ngx_int_t
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
85 ngx_http_addition_header_filter(ngx_http_request_t *r)
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
86 {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
87 ngx_http_addition_ctx_t *ctx;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
88 ngx_http_addition_conf_t *conf;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
89
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
90 if (r->headers_out.status != NGX_HTTP_OK || r != r->main) {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
91 return ngx_http_next_header_filter(r);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
92 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
93
180
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
94 conf = ngx_http_get_module_loc_conf(r, ngx_http_addition_filter_module);
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
95
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
96 if (conf->before_body.len == 0 && conf->after_body.len == 0) {
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
97 return ngx_http_next_header_filter(r);
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
98 }
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
99
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
100 if (ngx_strncasecmp(r->headers_out.content_type.data, "text/html",
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
101 sizeof("text/html") - 1)
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
102 != 0)
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
103 {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
104 return ngx_http_next_header_filter(r);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
105 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
106
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
107 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_addition_ctx_t));
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
108 if (ctx == NULL) {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
109 return NGX_ERROR;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
110 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
111
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
112 ngx_http_set_ctx(r, ctx, ngx_http_addition_filter_module);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
113
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
114 ngx_http_clear_content_length(r);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
115 ngx_http_clear_accept_ranges(r);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
116
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
117 return ngx_http_next_header_filter(r);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
118 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
119
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
120
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
121 static ngx_int_t
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
122 ngx_http_addition_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
123 {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
124 ngx_int_t rc;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
125 ngx_uint_t last;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
126 ngx_chain_t *cl;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
127 ngx_http_addition_ctx_t *ctx;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
128 ngx_http_addition_conf_t *conf;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
129
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
130 if (in == NULL || r->header_only) {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
131 return ngx_http_next_body_filter(r, in);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
132 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
133
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
134 ctx = ngx_http_get_module_ctx(r, ngx_http_addition_filter_module);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
135
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
136 if (ctx == NULL) {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
137 return ngx_http_next_body_filter(r, in);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
138 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
139
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
140 conf = ngx_http_get_module_loc_conf(r, ngx_http_addition_filter_module);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
141
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
142 if (!ctx->before_body_sent) {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
143 ctx->before_body_sent = 1;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
144
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
145 if (conf->before_body.len) {
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 194
diff changeset
146 if (ngx_http_subrequest(r, &conf->before_body, NULL, NULL, 0)
194
003bd800ec2a nginx 0.3.44
Igor Sysoev <http://sysoev.ru>
parents: 180
diff changeset
147 == NGX_ERROR)
003bd800ec2a nginx 0.3.44
Igor Sysoev <http://sysoev.ru>
parents: 180
diff changeset
148 {
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
149 return NGX_ERROR;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
150 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
151 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
152 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
153
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
154 last = 0;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
155
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
156 for (cl = in; cl; cl = cl->next) {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
157 if (cl->buf->last_buf) {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
158 cl->buf->last_buf = 0;
180
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
159 cl->buf->sync = 1;
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
160 last = 1;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
161 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
162 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
163
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
164 rc = ngx_http_next_body_filter(r, in);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
165
180
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
166 if (rc == NGX_ERROR || !last || conf->after_body.len == 0) {
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
167 return rc;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
168 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
169
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 194
diff changeset
170 if (ngx_http_subrequest(r, &conf->after_body, NULL, NULL, 0) == NGX_ERROR) {
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
171 return NGX_ERROR;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
172 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
173
180
4cd3e70c4d60 nginx 0.3.37
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
174 ngx_http_set_ctx(r, NULL, ngx_http_addition_filter_module);
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
175
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
176 return ngx_http_send_special(r, NGX_HTTP_LAST);
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
177 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
179
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
180 static ngx_int_t
230
38e7b94d63ac nginx 0.4.0
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
181 ngx_http_addition_filter_init(ngx_conf_t *cf)
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
182 {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
183 ngx_http_next_header_filter = ngx_http_top_header_filter;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
184 ngx_http_top_header_filter = ngx_http_addition_header_filter;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
185
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
186 ngx_http_next_body_filter = ngx_http_top_body_filter;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
187 ngx_http_top_body_filter = ngx_http_addition_body_filter;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
188
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
189 return NGX_OK;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
190 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
191
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
192
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
193 static void *
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
194 ngx_http_addition_create_conf(ngx_conf_t *cf)
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
195 {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
196 ngx_http_addition_conf_t *conf;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
197
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
198 conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_addition_conf_t));
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
199 if (conf == NULL) {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
200 return NGX_CONF_ERROR;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
201 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
202
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
203 /*
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
204 * set by ngx_pcalloc():
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
205 *
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
206 * conf->before_body.len = 0;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
207 * conf->before_body.date = NULL;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
208 * conf->after_body.len = 0;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
209 * conf->after_body.date = NULL;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
210 */
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
211
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
212 return conf;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
213 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
214
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
215
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
216 static char *
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
217 ngx_http_addition_merge_conf(ngx_conf_t *cf, void *parent, void *child)
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
218 {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
219 ngx_http_addition_conf_t *prev = parent;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
220 ngx_http_addition_conf_t *conf = child;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
221
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
222 ngx_conf_merge_str_value(conf->before_body, prev->before_body, "");
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
223 ngx_conf_merge_str_value(conf->after_body, prev->after_body, "");
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
224
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
225 return NGX_CONF_OK;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
226 }