comparison src/http/ngx_http_write_filter.c @ 10:4f3879d9b6f6

nginx-0.0.1-2002-09-11-19:18:33 import
author Igor Sysoev <igor@sysoev.ru>
date Wed, 11 Sep 2002 15:18:33 +0000
parents 6f58641241bb
children 77c7629a2627
comparison
equal deleted inserted replaced
9:6f58641241bb 10:4f3879d9b6f6
2 #include <ngx_config.h> 2 #include <ngx_config.h>
3 #include <ngx_core.h> 3 #include <ngx_core.h>
4 #include <ngx_hunk.h> 4 #include <ngx_hunk.h>
5 #include <ngx_event_write.h> 5 #include <ngx_event_write.h>
6 #include <ngx_http.h> 6 #include <ngx_http.h>
7 #include <ngx_http_config.h>
7 #include <ngx_http_output_filter.h> 8 #include <ngx_http_output_filter.h>
8 #include <ngx_http_write_filter.h> 9 #include <ngx_http_write_filter.h>
9 10
10 11
12 static ngx_command_t ngx_http_write_filter_commands[];
13
14 static void *ngx_http_write_filter_create_conf(ngx_pool_t *pool);
15
11 ngx_http_module_t ngx_http_write_filter_module = { 16 ngx_http_module_t ngx_http_write_filter_module = {
12 NGX_HTTP_MODULE 17 NGX_HTTP_MODULE,
18 NULL, /* create server config */
19 ngx_http_write_filter_create_conf, /* create location config */
20 ngx_http_write_filter_commands, /* module directives */
21 NULL, /* init module */
22 NULL /* init output body filter */
13 }; 23 };
14 24
15 25
16 /* STUB */ 26 static ngx_command_t ngx_http_write_filter_commands[] = {
17 /* */ 27
28 {"write_buffer", ngx_conf_set_size_slot,
29 offsetof(ngx_http_write_filter_conf_t, buffer_output),
30 NGX_HTTP_LOC_CONF, NGX_CONF_TAKE1,
31 "set write filter size to buffer output"},
32
33 {NULL}
34
35 };
18 36
19 37
20 int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in) 38 int ngx_http_write_filter(ngx_http_request_t *r, ngx_chain_t *in)
21 { 39 {
22 int last; 40 int last;
28 46
29 ctx = (ngx_http_write_filter_ctx_t *) 47 ctx = (ngx_http_write_filter_ctx_t *)
30 ngx_get_module_ctx(r->main ? r->main : r, 48 ngx_get_module_ctx(r->main ? r->main : r,
31 ngx_http_write_filter_module); 49 ngx_http_write_filter_module);
32 if (ctx == NULL) 50 if (ctx == NULL)
33 ngx_test_null(ctx, 51 ngx_http_create_ctx(r, ctx,
34 ngx_pcalloc(r->pool, sizeof(ngx_http_write_filter_ctx_t)), 52 ngx_http_write_filter_module,
35 NGX_ERROR); 53 sizeof(ngx_http_write_filter_ctx_t));
36 54
37 size = flush = 0; 55 size = flush = 0;
38 last = 0; 56 last = 0;
39 prev = &ctx->out; 57 prev = &ctx->out;
40 58
97 static void *ngx_http_write_filter_create_conf(ngx_pool_t *pool) 115 static void *ngx_http_write_filter_create_conf(ngx_pool_t *pool)
98 { 116 {
99 ngx_http_write_filter_conf_t *conf; 117 ngx_http_write_filter_conf_t *conf;
100 118
101 ngx_test_null(conf, 119 ngx_test_null(conf,
102 ngx_pcalloc(pool, sizeof(ngx_http_write_filter_conf_t)), 120 ngx_palloc(pool, sizeof(ngx_http_write_filter_conf_t)),
103 NULL); 121 NULL);
104 122
105 conf->buffer_output = 16384; 123 conf->buffer_output = NGX_CONF_UNSET;
124
125 return conf;
106 } 126 }
107
108 static void *ngx_http_write_filter_set_hunk_size(ngx_pool_t *pool, void *conf,
109 char *size)
110 {
111 ngx_http_write_filter_conf_t *cf = (ngx_http_write_filter_conf_t *) conf;
112
113 cf->buffer_output = atoi(size);
114 if (cf->buffer_output <= 0)
115 return "Error";
116
117 cf->buffer_output *= 1024;
118 return NULL;
119 }
120