Mercurial > hg > nginx-quic
comparison src/http/ngx_http_output_filter.c @ 96:a23d010f356d
nginx-0.0.1-2003-05-27-16:18:54 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 27 May 2003 12:18:54 +0000 |
parents | b48066122884 |
children | c9b243802a17 |
comparison
equal
deleted
inserted
replaced
95:b48066122884 | 96:a23d010f356d |
---|---|
14 | 14 |
15 static int ngx_http_output_filter_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src); | 15 static int ngx_http_output_filter_copy_hunk(ngx_hunk_t *dst, ngx_hunk_t *src); |
16 static void *ngx_http_output_filter_create_conf(ngx_pool_t *pool); | 16 static void *ngx_http_output_filter_create_conf(ngx_pool_t *pool); |
17 static char *ngx_http_output_filter_merge_conf(ngx_pool_t *pool, | 17 static char *ngx_http_output_filter_merge_conf(ngx_pool_t *pool, |
18 void *parent, void *child); | 18 void *parent, void *child); |
19 static void ngx_http_output_filter_init(ngx_pool_t *pool, | |
20 ngx_http_conf_filter_t *cf); | |
21 | 19 |
22 | 20 |
23 static ngx_command_t ngx_http_output_filter_commands[] = { | 21 static ngx_command_t ngx_http_output_filter_commands[] = { |
24 | 22 |
25 {ngx_string("output_buffer"), | 23 {ngx_string("output_buffer"), |
27 ngx_conf_set_size_slot, | 25 ngx_conf_set_size_slot, |
28 NGX_HTTP_LOC_CONF_OFFSET, | 26 NGX_HTTP_LOC_CONF_OFFSET, |
29 offsetof(ngx_http_output_filter_conf_t, hunk_size), | 27 offsetof(ngx_http_output_filter_conf_t, hunk_size), |
30 NULL}, | 28 NULL}, |
31 | 29 |
32 {ngx_null_string, 0, NULL, 0, 0, NULL} | 30 ngx_null_command |
33 }; | 31 }; |
34 | 32 |
35 | 33 |
36 static ngx_http_module_t ngx_http_output_filter_module_ctx = { | 34 static ngx_http_module_t ngx_http_output_filter_module_ctx = { |
37 NGX_HTTP_MODULE, | |
38 | |
39 NULL, /* create main configuration */ | 35 NULL, /* create main configuration */ |
40 NULL, /* init main configuration */ | 36 NULL, /* init main configuration */ |
41 | 37 |
42 NULL, /* create server configuration */ | 38 NULL, /* create server configuration */ |
43 NULL, /* merge server configuration */ | 39 NULL, /* merge server configuration */ |
46 ngx_http_output_filter_merge_conf /* merge location configuration */ | 42 ngx_http_output_filter_merge_conf /* merge location configuration */ |
47 }; | 43 }; |
48 | 44 |
49 | 45 |
50 ngx_module_t ngx_http_output_filter_module = { | 46 ngx_module_t ngx_http_output_filter_module = { |
47 NGX_MODULE, | |
51 &ngx_http_output_filter_module_ctx, /* module context */ | 48 &ngx_http_output_filter_module_ctx, /* module context */ |
52 0, /* module index */ | |
53 ngx_http_output_filter_commands, /* module directives */ | 49 ngx_http_output_filter_commands, /* module directives */ |
54 NGX_HTTP_MODULE_TYPE, /* module type */ | 50 NGX_HTTP_MODULE, /* module type */ |
55 NULL /* init module */ | 51 NULL /* init module */ |
56 }; | 52 }; |
57 | 53 |
58 | 54 |
59 #define next_filter (*ngx_http_top_body_filter) | 55 #define next_filter (*ngx_http_top_body_filter) |
71 size_t size; | 67 size_t size; |
72 ngx_chain_t *ce, *le; | 68 ngx_chain_t *ce, *le; |
73 ngx_http_output_filter_ctx_t *ctx; | 69 ngx_http_output_filter_ctx_t *ctx; |
74 ngx_http_output_filter_conf_t *conf; | 70 ngx_http_output_filter_conf_t *conf; |
75 | 71 |
76 ctx = (ngx_http_output_filter_ctx_t *) | 72 ctx = ngx_http_get_module_ctx(r->main ? r->main : r, |
77 ngx_http_get_module_ctx(r->main ? r->main : r, | 73 ngx_http_output_filter_module); |
78 ngx_http_output_filter_module_ctx); | |
79 | 74 |
80 if (ctx == NULL) { | 75 if (ctx == NULL) { |
81 ngx_http_create_ctx(r, ctx, ngx_http_output_filter_module_ctx, | 76 ngx_http_create_ctx(r, ctx, ngx_http_output_filter_module, |
82 sizeof(ngx_http_output_filter_ctx_t), NGX_ERROR); | 77 sizeof(ngx_http_output_filter_ctx_t), NGX_ERROR); |
83 } | 78 } |
84 | 79 |
85 /* the short path for the case when the chain ctx->incoming is empty | 80 /* the short path for the case when the chain ctx->incoming is empty |
86 and there is no hunk or the hunk does not require the copy */ | 81 and there is no hunk or the hunk does not require the copy */ |
115 } | 110 } |
116 | 111 |
117 /* allocate our hunk if it's needed */ | 112 /* allocate our hunk if it's needed */ |
118 if (ctx->hunk == NULL) { | 113 if (ctx->hunk == NULL) { |
119 | 114 |
120 conf = (ngx_http_output_filter_conf_t *) | 115 conf = ngx_http_get_module_loc_conf(r->main ? r->main : r, |
121 ngx_http_get_module_loc_conf(r->main ? r->main : r, | 116 ngx_http_output_filter_module); |
122 ngx_http_output_filter_module_ctx); | |
123 | 117 |
124 if (hunk->type & NGX_HUNK_LAST) { | 118 if (hunk->type & NGX_HUNK_LAST) { |
125 if (hunk->type & NGX_HUNK_IN_MEMORY) { | 119 if (hunk->type & NGX_HUNK_IN_MEMORY) { |
126 size = hunk->last - hunk->pos; | 120 size = hunk->last - hunk->pos; |
127 } else { | 121 } else { |
305 | 299 |
306 return NGX_OK; | 300 return NGX_OK; |
307 } | 301 } |
308 | 302 |
309 | 303 |
310 static void ngx_http_output_filter_init(ngx_pool_t *pool, | |
311 ngx_http_conf_filter_t *cf) | |
312 { | |
313 #if 0 | |
314 next_filter = cf->output_body_filter; | |
315 cf->output_body_filter = NULL; | |
316 #endif | |
317 } | |
318 | |
319 | |
320 static void *ngx_http_output_filter_create_conf(ngx_pool_t *pool) | 304 static void *ngx_http_output_filter_create_conf(ngx_pool_t *pool) |
321 { | 305 { |
322 ngx_http_output_filter_conf_t *conf; | 306 ngx_http_output_filter_conf_t *conf; |
323 | 307 |
324 ngx_test_null(conf, | 308 ngx_test_null(conf, |
325 ngx_pcalloc(pool, sizeof(ngx_http_output_filter_conf_t)), | 309 ngx_palloc(pool, sizeof(ngx_http_output_filter_conf_t)), |
326 NULL); | 310 NULL); |
327 | 311 |
328 conf->hunk_size = NGX_CONF_UNSET; | 312 conf->hunk_size = NGX_CONF_UNSET; |
329 | 313 |
330 return conf; | 314 return conf; |
332 | 316 |
333 | 317 |
334 static char *ngx_http_output_filter_merge_conf(ngx_pool_t *pool, | 318 static char *ngx_http_output_filter_merge_conf(ngx_pool_t *pool, |
335 void *parent, void *child) | 319 void *parent, void *child) |
336 { | 320 { |
337 ngx_http_output_filter_conf_t *prev = | 321 ngx_http_output_filter_conf_t *prev = parent; |
338 (ngx_http_output_filter_conf_t *) parent; | 322 ngx_http_output_filter_conf_t *conf = child; |
339 ngx_http_output_filter_conf_t *conf = | |
340 (ngx_http_output_filter_conf_t *) child; | |
341 | 323 |
342 ngx_conf_merge_size_value(conf->hunk_size, prev->hunk_size, 32768); | 324 ngx_conf_merge_size_value(conf->hunk_size, prev->hunk_size, 32768); |
343 | 325 |
344 return NULL; | 326 return NULL; |
345 } | 327 } |