Mercurial > hg > nginx
comparison src/http/ngx_http.c @ 485:4ebe09b07e30 release-0.1.17
nginx-0.1.17-RELEASE import
*) Change: the ngx_http_rewrite_module was rewritten from the scratch.
Now it is possible to redirect, to return the error codes, to check
the variables and referrers. The directives can be used inside
locations. The redirect directive was canceled.
*) Feature: the ngx_http_geo_module.
*) Feature: the proxy_set_x_var and fastcgi_set_var directives.
*) Bugfix: the location configuration with "=" modifier may be used in
another location.
*) Bugfix: the correct content type was set only for requests that use
small caps letters in extension.
*) Bugfix: if the proxy_pass or fastcgi_pass directives were set in the
location, and access was denied, and the error was redirected to a
static page, then the segmentation fault occurred.
*) Bugfix: if in a proxied "Location" header was a relative URL, then a
host name and a slash were added to them; the bug had appeared in
0.1.14.
*) Bugfix: the system error message was not logged on Linux.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Thu, 03 Feb 2005 19:33:37 +0000 |
parents | ad1e9ebf93bb |
children | 64d9afb209da |
comparison
equal
deleted
inserted
replaced
484:60452f1c0c62 | 485:4ebe09b07e30 |
---|---|
24 ngx_array_t *locations, | 24 ngx_array_t *locations, |
25 void **loc_conf, | 25 void **loc_conf, |
26 ngx_http_module_t *module, | 26 ngx_http_module_t *module, |
27 ngx_uint_t ctx_index); | 27 ngx_uint_t ctx_index); |
28 | 28 |
29 int ngx_http_max_module; | 29 ngx_uint_t ngx_http_max_module; |
30 | 30 |
31 ngx_uint_t ngx_http_total_requests; | 31 ngx_uint_t ngx_http_total_requests; |
32 uint64_t ngx_http_total_sent; | 32 uint64_t ngx_http_total_sent; |
33 | 33 |
34 | 34 |
87 #if (NGX_WIN32) | 87 #if (NGX_WIN32) |
88 ngx_iocp_conf_t *iocpcf; | 88 ngx_iocp_conf_t *iocpcf; |
89 #endif | 89 #endif |
90 | 90 |
91 #if (NGX_SUPPRESS_WARN) | 91 #if (NGX_SUPPRESS_WARN) |
92 /* MSVC thinks 'in_ports' may be used without having been initialized */ | 92 /* MSVC thinks "in_ports" may be used without having been initialized */ |
93 ngx_memzero(&in_ports, sizeof(ngx_array_t)); | 93 ngx_memzero(&in_ports, sizeof(ngx_array_t)); |
94 #endif | 94 #endif |
95 | 95 |
96 | 96 |
97 /* the main http context */ | 97 /* the main http context */ |
98 | 98 |
99 ngx_test_null(ctx, | 99 if (!(ctx = ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)))) { |
100 ngx_pcalloc(cf->pool, sizeof(ngx_http_conf_ctx_t)), | 100 return NGX_CONF_ERROR; |
101 NGX_CONF_ERROR); | 101 } |
102 | 102 |
103 *(ngx_http_conf_ctx_t **) conf = ctx; | 103 *(ngx_http_conf_ctx_t **) conf = ctx; |
104 | |
104 | 105 |
105 /* count the number of the http modules and set up their indices */ | 106 /* count the number of the http modules and set up their indices */ |
106 | 107 |
107 ngx_http_max_module = 0; | 108 ngx_http_max_module = 0; |
108 for (m = 0; ngx_modules[m]; m++) { | 109 for (m = 0; ngx_modules[m]; m++) { |
111 } | 112 } |
112 | 113 |
113 ngx_modules[m]->ctx_index = ngx_http_max_module++; | 114 ngx_modules[m]->ctx_index = ngx_http_max_module++; |
114 } | 115 } |
115 | 116 |
116 /* the main http main_conf, it's the same in the all http contexts */ | 117 |
117 | 118 /* the http main_conf context, it is the same in the all http contexts */ |
118 ngx_test_null(ctx->main_conf, | 119 |
119 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module), | 120 ctx->main_conf = ngx_pcalloc(cf->pool, |
120 NGX_CONF_ERROR); | 121 sizeof(void *) * ngx_http_max_module); |
121 | 122 if (ctx->main_conf == NULL) { |
122 /* the http null srv_conf, it's used to merge the server{}s' srv_conf's */ | 123 return NGX_CONF_ERROR; |
123 ngx_test_null(ctx->srv_conf, | 124 } |
124 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module), | 125 |
125 NGX_CONF_ERROR); | 126 |
126 | 127 /* |
127 /* the http null loc_conf, it's used to merge the server{}s' loc_conf's */ | 128 * the http null srv_conf context, it is used to merge |
128 ngx_test_null(ctx->loc_conf, | 129 * the server{}s' srv_conf's |
129 ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module), | 130 */ |
130 NGX_CONF_ERROR); | 131 |
131 | 132 ctx->srv_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module); |
132 | 133 if (ctx->srv_conf == NULL) { |
133 /* create the main_conf, srv_conf and loc_conf in all http modules */ | 134 return NGX_CONF_ERROR; |
135 } | |
136 | |
137 | |
138 /* | |
139 * the http null loc_conf context, it is used to merge | |
140 * the server{}s' loc_conf's | |
141 */ | |
142 | |
143 ctx->loc_conf = ngx_pcalloc(cf->pool, sizeof(void *) * ngx_http_max_module); | |
144 if (ctx->loc_conf == NULL) { | |
145 return NGX_CONF_ERROR; | |
146 } | |
147 | |
148 | |
149 /* | |
150 * create the main_conf's, the null srv_conf's, and the null loc_conf's | |
151 * of the all http modules | |
152 */ | |
134 | 153 |
135 for (m = 0; ngx_modules[m]; m++) { | 154 for (m = 0; ngx_modules[m]; m++) { |
136 if (ngx_modules[m]->type != NGX_HTTP_MODULE) { | 155 if (ngx_modules[m]->type != NGX_HTTP_MODULE) { |
137 continue; | 156 continue; |
138 } | 157 } |
145 return NGX_CONF_ERROR; | 164 return NGX_CONF_ERROR; |
146 } | 165 } |
147 } | 166 } |
148 | 167 |
149 if (module->create_main_conf) { | 168 if (module->create_main_conf) { |
150 ngx_test_null(ctx->main_conf[mi], module->create_main_conf(cf), | 169 if (!(ctx->main_conf[mi] = module->create_main_conf(cf))) { |
151 NGX_CONF_ERROR); | 170 return NGX_CONF_ERROR; |
171 } | |
152 } | 172 } |
153 | 173 |
154 if (module->create_srv_conf) { | 174 if (module->create_srv_conf) { |
155 ngx_test_null(ctx->srv_conf[mi], module->create_srv_conf(cf), | 175 if (!(ctx->srv_conf[mi] = module->create_srv_conf(cf))) { |
156 NGX_CONF_ERROR); | 176 return NGX_CONF_ERROR; |
177 } | |
157 } | 178 } |
158 | 179 |
159 if (module->create_loc_conf) { | 180 if (module->create_loc_conf) { |
160 ngx_test_null(ctx->loc_conf[mi], module->create_loc_conf(cf), | 181 if (!(ctx->loc_conf[mi] = module->create_loc_conf(cf))) { |
161 NGX_CONF_ERROR); | 182 return NGX_CONF_ERROR; |
162 } | 183 } |
163 } | 184 } |
185 } | |
186 | |
164 | 187 |
165 /* parse inside the http{} block */ | 188 /* parse inside the http{} block */ |
166 | 189 |
167 pcf = *cf; | 190 pcf = *cf; |
168 cf->ctx = ctx; | 191 cf->ctx = ctx; |
234 module, mi); | 257 module, mi); |
235 if (rv != NGX_CONF_OK) { | 258 if (rv != NGX_CONF_OK) { |
236 *cf = pcf; | 259 *cf = pcf; |
237 return rv; | 260 return rv; |
238 } | 261 } |
239 | 262 } |
240 #if 0 | 263 } |
241 clcfp = (ngx_http_core_loc_conf_t **) cscfp[s]->locations.elts; | 264 } |
242 | 265 |
243 for (l = 0; l < cscfp[s]->locations.nelts; l++) { | 266 |
244 rv = module->merge_loc_conf(cf, | 267 /* we needed http{}'s cf->ctx while the merging configuration */ |
245 cscfp[s]->ctx->loc_conf[mi], | |
246 clcfp[l]->loc_conf[mi]); | |
247 if (rv != NGX_CONF_OK) { | |
248 *cf = pcf; | |
249 return rv; | |
250 } | |
251 } | |
252 #endif | |
253 } | |
254 } | |
255 } | |
256 | |
257 /* we needed "http"'s cf->ctx while merging configuration */ | |
258 *cf = pcf; | 268 *cf = pcf; |
259 | 269 |
270 | |
260 /* init lists of the handlers */ | 271 /* init lists of the handlers */ |
261 | 272 |
262 ngx_init_array(cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers, | 273 if (ngx_array_init(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers, |
263 cf->cycle->pool, 10, sizeof(ngx_http_handler_pt), | 274 cf->pool, 1, sizeof(ngx_http_handler_pt)) == NGX_ERROR) |
264 NGX_CONF_ERROR); | 275 { |
276 return NGX_CONF_ERROR; | |
277 } | |
278 | |
265 cmcf->phases[NGX_HTTP_REWRITE_PHASE].type = NGX_OK; | 279 cmcf->phases[NGX_HTTP_REWRITE_PHASE].type = NGX_OK; |
266 | 280 |
267 | 281 |
268 /* the special find config phase for single handler */ | 282 /* the special find config phase for a single handler */ |
269 | 283 |
270 ngx_init_array(cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers, | 284 if (ngx_array_init(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers, |
271 cf->cycle->pool, 1, sizeof(ngx_http_handler_pt), | 285 cf->pool, 1, sizeof(ngx_http_handler_pt)) == NGX_ERROR) |
272 NGX_CONF_ERROR); | 286 { |
287 return NGX_CONF_ERROR; | |
288 } | |
289 | |
273 cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].type = NGX_OK; | 290 cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].type = NGX_OK; |
274 | 291 |
275 ngx_test_null(h, ngx_push_array( | 292 h = ngx_push_array(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers); |
276 &cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers), | 293 if (h == NULL) { |
277 NGX_CONF_ERROR); | 294 return NGX_CONF_ERROR; |
295 } | |
296 | |
278 *h = ngx_http_find_location_config; | 297 *h = ngx_http_find_location_config; |
279 | 298 |
280 | 299 |
281 ngx_init_array(cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers, | 300 if (ngx_array_init(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers, |
282 cf->cycle->pool, 10, sizeof(ngx_http_handler_pt), | 301 cf->pool, 1, sizeof(ngx_http_handler_pt)) == NGX_ERROR) |
283 NGX_CONF_ERROR); | 302 { |
303 return NGX_CONF_ERROR; | |
304 } | |
305 | |
284 cmcf->phases[NGX_HTTP_ACCESS_PHASE].type = NGX_DECLINED; | 306 cmcf->phases[NGX_HTTP_ACCESS_PHASE].type = NGX_DECLINED; |
285 | 307 |
286 | 308 |
287 ngx_init_array(cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers, | 309 if (ngx_array_init(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers, |
288 cf->cycle->pool, 10, sizeof(ngx_http_handler_pt), | 310 cf->pool, 4, sizeof(ngx_http_handler_pt)) == NGX_ERROR) |
289 NGX_CONF_ERROR); | 311 { |
312 return NGX_CONF_ERROR; | |
313 } | |
314 | |
290 cmcf->phases[NGX_HTTP_CONTENT_PHASE].type = NGX_OK; | 315 cmcf->phases[NGX_HTTP_CONTENT_PHASE].type = NGX_OK; |
291 | 316 |
292 | 317 |
293 /* | 318 /* |
294 * create the lists of ports, addresses and server names | 319 * create the lists of ports, addresses and server names |