Mercurial > hg > nginx-vendor-0-5
comparison src/http/ngx_http_write_filter_module.c @ 58:b55cbf18157e NGINX_0_1_29
nginx 0.1.29
*) Feature: the ngx_http_ssi_module supports "include virtual" command.
*) Feature: the ngx_http_ssi_module supports the condition command like
'if expr="$NAME"' and "else" and "endif" commands. Only one nested
level is supported.
*) Feature: the ngx_http_ssi_module supports the DATE_LOCAL and
DATE_GMT variables and "config timefmt" command.
*) Feature: the "ssi_ignore_recycled_buffers" directive.
*) Bugfix: the "echo" command did not show the default value for the
empty QUERY_STRING variable.
*) Change: the ngx_http_proxy_module was rewritten.
*) Feature: the "proxy_redirect", "proxy_pass_request_headers",
"proxy_pass_request_body", and "proxy_method" directives.
*) Feature: the "proxy_set_header" directive. The "proxy_x_var" was
canceled and must be replaced with the proxy_set_header directive.
*) Change: the "proxy_preserve_host" is canceled and must be replaced
with the "proxy_set_header Host $host" and the "proxy_redirect off"
directives, the "proxy_set_header Host $host:$proxy_port" directive
and the appropriate proxy_redirect directives.
*) Change: the "proxy_set_x_real_ip" is canceled and must be replaced
with the "proxy_set_header X-Real-IP $remote_addr" directive.
*) Change: the "proxy_add_x_forwarded_for" is canceled and must be
replaced with
the "proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for"
directive.
*) Change: the "proxy_set_x_url" is canceled and must be replaced with
the "proxy_set_header X-URL http://$host:$server_port$request_uri"
directive.
*) Feature: the "fastcgi_param" directive.
*) Change: the "fastcgi_root", "fastcgi_set_var" and "fastcgi_params"
directive are canceled and must be replaced with the fastcgi_param
directives.
*) Feature: the "index" directive can use the variables.
*) Feature: the "index" directive can be used at http and server levels.
*) Change: the last index only in the "index" directive can be absolute.
*) Feature: the "rewrite" directive can use the variables.
*) Feature: the "internal" directive.
*) Feature: the CONTENT_LENGTH, CONTENT_TYPE, REMOTE_PORT, SERVER_ADDR,
SERVER_PORT, SERVER_PROTOCOL, DOCUMENT_ROOT, SERVER_NAME,
REQUEST_METHOD, REQUEST_URI, and REMOTE_USER variables.
*) Change: nginx now passes the invalid lines in a client request
headers or a backend response header.
*) Bugfix: if the backend did not transfer response for a long time and
the "send_timeout" was less than "proxy_read_timeout", then nginx
returned the 408 response.
*) Bugfix: the segmentation fault was occurred if the backend sent an
invalid line in response header; bug appeared in 0.1.26.
*) Bugfix: the segmentation fault may occurred in FastCGI fault
tolerance configuration.
*) Bugfix: the "expires" directive did not remove the previous
"Expires" and "Cache-Control" headers.
*) Bugfix: nginx did not take into account trailing dot in "Host"
header line.
*) Bugfix: the ngx_http_auth_module did not work under Linux.
*) Bugfix: the rewrite directive worked incorrectly, if the arguments
were in a request.
*) Bugfix: nginx could not be built on MacOS X.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Thu, 12 May 2005 00:00:00 +0400 |
parents | 3050baa54a26 |
children | df7d3fff122b |
comparison
equal
deleted
inserted
replaced
57:5df375c55338 | 58:b55cbf18157e |
---|---|
8 #include <ngx_core.h> | 8 #include <ngx_core.h> |
9 #include <ngx_event.h> | 9 #include <ngx_event.h> |
10 #include <ngx_http.h> | 10 #include <ngx_http.h> |
11 | 11 |
12 | 12 |
13 typedef struct { | |
14 ngx_chain_t *out; | |
15 } ngx_http_write_filter_ctx_t; | |
16 | |
17 | |
18 static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle); | 13 static ngx_int_t ngx_http_write_filter_init(ngx_cycle_t *cycle); |
19 | 14 |
20 | 15 |
21 ngx_http_module_t ngx_http_write_filter_module_ctx = { | 16 ngx_http_module_t ngx_http_write_filter_module_ctx = { |
22 NULL, /* pre conf */ | 17 NULL, /* preconfiguration */ |
18 NULL, /* postconfiguration */ | |
23 | 19 |
24 NULL, /* create main configuration */ | 20 NULL, /* create main configuration */ |
25 NULL, /* init main configuration */ | 21 NULL, /* init main configuration */ |
26 | 22 |
27 NULL, /* create server configuration */ | 23 NULL, /* create server configuration */ |
31 NULL, /* merge location configuration */ | 27 NULL, /* merge location configuration */ |
32 }; | 28 }; |
33 | 29 |
34 | 30 |
35 ngx_module_t ngx_http_write_filter_module = { | 31 ngx_module_t ngx_http_write_filter_module = { |
36 NGX_MODULE, | 32 NGX_MODULE_V1, |
37 &ngx_http_write_filter_module_ctx, /* module context */ | 33 &ngx_http_write_filter_module_ctx, /* module context */ |
38 NULL, /* module directives */ | 34 NULL, /* module directives */ |
39 NGX_HTTP_MODULE, /* module type */ | 35 NGX_HTTP_MODULE, /* module type */ |
40 ngx_http_write_filter_init, /* init module */ | 36 ngx_http_write_filter_init, /* init module */ |
41 NULL /* init process */ | 37 NULL /* init process */ |
43 | 39 |
44 | 40 |
45 ngx_int_t | 41 ngx_int_t |
46 ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) | 42 ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) |
47 { | 43 { |
48 off_t size, sent; | 44 off_t size, sent; |
49 ngx_uint_t last, flush; | 45 ngx_uint_t last, flush; |
50 ngx_chain_t *cl, *ln, **ll, *chain; | 46 ngx_chain_t *cl, *ln, **ll, *chain; |
51 ngx_connection_t *c; | 47 ngx_connection_t *c; |
52 ngx_http_core_loc_conf_t *clcf; | 48 ngx_http_core_loc_conf_t *clcf; |
53 ngx_http_write_filter_ctx_t *ctx; | |
54 | |
55 ctx = ngx_http_get_module_ctx(r->main ? r->main : r, | |
56 ngx_http_write_filter_module); | |
57 | |
58 if (ctx == NULL) { | |
59 | |
60 ctx = ngx_pcalloc(r->pool, sizeof(ngx_http_write_filter_ctx_t)); | |
61 if (ctx == NULL) { | |
62 return NGX_ERROR; | |
63 } | |
64 | |
65 ngx_http_set_ctx(r, ctx, ngx_http_write_filter_module); | |
66 } | |
67 | 49 |
68 size = 0; | 50 size = 0; |
69 flush = 0; | 51 flush = 0; |
70 last = 0; | 52 last = 0; |
71 ll = &ctx->out; | 53 ll = &r->out; |
72 | 54 |
73 /* find the size, the flush point and the last link of the saved chain */ | 55 /* find the size, the flush point and the last link of the saved chain */ |
74 | 56 |
75 for (cl = ctx->out; cl; cl = cl->next) { | 57 for (cl = r->out; cl; cl = cl->next) { |
76 ll = &cl->next; | 58 ll = &cl->next; |
77 | 59 |
78 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, r->connection->log, 0, | 60 ngx_log_debug7(NGX_LOG_DEBUG_EVENT, r->connection->log, 0, |
79 "write old buf t:%d f:%d %p, pos %p, size: %z " | 61 "write old buf t:%d f:%d %p, pos %p, size: %z " |
80 "file: %O, size: %z", | 62 "file: %O, size: %z", |
172 c = r->connection; | 154 c = r->connection; |
173 | 155 |
174 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, | 156 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, c->log, 0, |
175 "http write filter: l:%d f:%d s:%O", last, flush, size); | 157 "http write filter: l:%d f:%d s:%O", last, flush, size); |
176 | 158 |
177 clcf = ngx_http_get_module_loc_conf(r->main ? r->main : r, | 159 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
178 ngx_http_core_module); | |
179 | 160 |
180 /* | 161 /* |
181 * avoid the output if there is no last buf, no flush point, | 162 * avoid the output if there are no last buf, no flush point, |
182 * there are the incoming bufs and the size of all bufs | 163 * there are the incoming bufs and the size of all bufs |
183 * is smaller than "postpone_output" directive | 164 * is smaller than "postpone_output" directive |
184 */ | 165 */ |
185 | 166 |
186 if (!last && !flush && in && size < (off_t) clcf->postpone_output) { | 167 if (!last && !flush && in && size < (off_t) clcf->postpone_output) { |
187 return NGX_OK; | 168 return NGX_OK; |
188 } | 169 } |
189 | 170 |
171 /* | |
172 * avoid the output if there are no incoming bufs but there are | |
173 * the postponed requests or data | |
174 */ | |
175 | |
176 if (in == NULL && r->postponed) { | |
177 return NGX_OK; | |
178 } | |
179 | |
190 if (c->write->delayed) { | 180 if (c->write->delayed) { |
191 return NGX_AGAIN; | 181 return NGX_AGAIN; |
192 } | 182 } |
193 | 183 |
194 if (size == 0 && !c->buffered) { | 184 if (size == 0 && !c->buffered) { |
195 if (last) { | 185 if (last) { |
186 r->out = NULL; | |
196 return NGX_OK; | 187 return NGX_OK; |
197 } | 188 } |
198 | 189 |
199 if (flush) { | 190 if (flush) { |
200 do { | 191 do { |
201 ctx->out = ctx->out->next; | 192 r->out = r->out->next; |
202 } | 193 } |
203 while (ctx->out); | 194 while (r->out); |
204 | 195 |
205 return NGX_OK; | 196 return NGX_OK; |
206 } | 197 } |
207 | 198 |
208 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | 199 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
213 return NGX_ERROR; | 204 return NGX_ERROR; |
214 } | 205 } |
215 | 206 |
216 sent = c->sent; | 207 sent = c->sent; |
217 | 208 |
218 chain = c->send_chain(c, ctx->out, clcf->limit_rate); | 209 chain = c->send_chain(c, r->out, clcf->limit_rate); |
219 | 210 |
220 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, | 211 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, c->log, 0, |
221 "http write filter %p", chain); | 212 "http write filter %p", chain); |
222 | 213 |
223 if (clcf->limit_rate) { | 214 if (clcf->limit_rate) { |
229 | 220 |
230 if (chain == NGX_CHAIN_ERROR) { | 221 if (chain == NGX_CHAIN_ERROR) { |
231 return NGX_ERROR; | 222 return NGX_ERROR; |
232 } | 223 } |
233 | 224 |
234 for (cl = ctx->out; cl && cl != chain; /* void */) { | 225 for (cl = r->out; cl && cl != chain; /* void */) { |
235 ln = cl; | 226 ln = cl; |
236 cl = cl->next; | 227 cl = cl->next; |
237 ngx_free_chain(r->pool, ln); | 228 ngx_free_chain(r->pool, ln); |
238 } | 229 } |
239 | 230 |
240 ctx->out = chain; | 231 r->out = chain; |
241 | 232 |
242 if (chain || (last && c->buffered)) { | 233 if (chain || (last && c->buffered)) { |
243 return NGX_AGAIN; | 234 return NGX_AGAIN; |
244 } | 235 } |
245 | 236 |