Mercurial > hg > nginx
comparison src/http/ngx_http.c @ 71:59229033ae93
nginx-0.0.1-2003-04-08-19:40:10 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Tue, 08 Apr 2003 15:40:10 +0000 |
parents | e43f406e4525 |
children | b2ece31c976a |
comparison
equal
deleted
inserted
replaced
70:e320bf51c4e3 | 71:59229033ae93 |
---|---|
31 ngx_array_t ngx_http_translate_handlers; | 31 ngx_array_t ngx_http_translate_handlers; |
32 ngx_array_t ngx_http_index_handlers; | 32 ngx_array_t ngx_http_index_handlers; |
33 | 33 |
34 | 34 |
35 int (*ngx_http_top_header_filter) (ngx_http_request_t *r); | 35 int (*ngx_http_top_header_filter) (ngx_http_request_t *r); |
36 int (*ngx_http_top_body_filter) (ngx_http_request_t *r, ngx_chain_t *ch); | |
36 | 37 |
37 | 38 |
38 static ngx_str_t http_name = ngx_string("http"); | 39 static ngx_str_t http_name = ngx_string("http"); |
39 | 40 |
40 | 41 |
55 &http_name, /* module context */ | 56 &http_name, /* module context */ |
56 ngx_http_commands, /* module directives */ | 57 ngx_http_commands, /* module directives */ |
57 NGX_CORE_MODULE_TYPE, /* module type */ | 58 NGX_CORE_MODULE_TYPE, /* module type */ |
58 NULL /* init module */ | 59 NULL /* init module */ |
59 }; | 60 }; |
60 | |
61 | |
62 | |
63 static void ngx_http_init_filters(ngx_pool_t *pool, ngx_module_t **modules) | |
64 { | |
65 int i; | |
66 ngx_http_module_t *module; | |
67 ngx_http_conf_filter_t cf; | |
68 | |
69 cf.output_header_filter = NULL; | |
70 cf.output_body_filter = NULL; | |
71 | |
72 for (i = 0; modules[i]; i++) { | |
73 if (modules[i]->type != NGX_HTTP_MODULE_TYPE) { | |
74 continue; | |
75 } | |
76 | |
77 module = (ngx_http_module_t *) modules[i]->ctx; | |
78 | |
79 if (module->init_filters) { | |
80 module->init_filters(pool, &cf); | |
81 } | |
82 } | |
83 | |
84 ngx_http_top_header_filter = cf.output_header_filter; | |
85 } | |
86 | 61 |
87 | 62 |
88 static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy) | 63 static char *ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, char *dummy) |
89 { | 64 { |
90 int i, s, l, p, a, n, start; | 65 int i, s, l, p, a, n, start; |
106 | 81 |
107 ngx_test_null(ctx, | 82 ngx_test_null(ctx, |
108 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), | 83 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), |
109 NGX_CONF_ERROR); | 84 NGX_CONF_ERROR); |
110 | 85 |
86 ngx_http_max_module = 0; | |
111 for (i = 0; ngx_modules[i]; i++) { | 87 for (i = 0; ngx_modules[i]; i++) { |
112 if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) { | 88 if (ngx_modules[i]->type != NGX_HTTP_MODULE_TYPE) { |
113 continue; | 89 continue; |
114 } | 90 } |
115 | 91 |
116 ngx_modules[i]->index = ngx_http_max_module++; | 92 module = (ngx_http_module_t *) ngx_modules[i]->ctx; |
93 | |
94 module->index = ngx_http_max_module++; | |
117 } | 95 } |
118 | 96 |
119 /* null loc_conf */ | 97 /* null loc_conf */ |
120 ngx_test_null(ctx->loc_conf, | 98 ngx_test_null(ctx->loc_conf, |
121 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module), | 99 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module), |
166 ngx_init_array(ngx_http_translate_handlers, | 144 ngx_init_array(ngx_http_translate_handlers, |
167 cf->pool, 10, sizeof(ngx_http_handler_pt), NGX_CONF_ERROR); | 145 cf->pool, 10, sizeof(ngx_http_handler_pt), NGX_CONF_ERROR); |
168 | 146 |
169 ngx_init_array(ngx_http_index_handlers, | 147 ngx_init_array(ngx_http_index_handlers, |
170 cf->pool, 3, sizeof(ngx_http_handler_pt), NGX_CONF_ERROR); | 148 cf->pool, 3, sizeof(ngx_http_handler_pt), NGX_CONF_ERROR); |
171 | |
172 ngx_http_init_filters(cf->pool, ngx_modules); | |
173 | 149 |
174 /* create lists of ports, addresses and server names */ | 150 /* create lists of ports, addresses and server names */ |
175 | 151 |
176 ngx_init_array(in_ports, cf->pool, 10, sizeof(ngx_http_in_port_t), | 152 ngx_init_array(in_ports, cf->pool, 10, sizeof(ngx_http_in_port_t), |
177 NGX_CONF_ERROR); | 153 NGX_CONF_ERROR); |