Mercurial > hg > nginx-quic
comparison src/http/ngx_http.c @ 681:7e24168b0853 release-0.4.0
nginx-0.4.0-RELEASE import
*) Change in internal API: the HTTP modules initialization was moved
from the init module phase to the HTTP postconfiguration phase.
*) Change: now the request body is not read beforehand for the
ngx_http_perl_module: it's required to start the reading using the
$r->has_request_body method.
*) Feature: the ngx_http_perl_module supports the DECLINED return code.
*) Feature: the ngx_http_dav_module supports the incoming "Date" header
line for the PUT method.
*) Feature: the "ssi" directive is available inside the "if" block.
*) Bugfix: a segmentation fault occurred if there was an "index"
directive with variables and the first index name was without
variables; the bug had appeared in 0.1.29.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 30 Aug 2006 10:39:17 +0000 |
parents | 1e720b0be7ec |
children | e3df50b4a4fd |
comparison
equal
deleted
inserted
replaced
680:63a949f7ed4f | 681:7e24168b0853 |
---|---|
73 static char * | 73 static char * |
74 ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) | 74 ngx_http_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf) |
75 { | 75 { |
76 char *rv; | 76 char *rv; |
77 u_char ch; | 77 u_char ch; |
78 ngx_int_t rc; | 78 ngx_int_t rc, j; |
79 ngx_uint_t mi, m, s, l, p, a, i; | 79 ngx_uint_t mi, m, s, l, p, a, i, n; |
80 ngx_uint_t find_config_index, use_rewrite, use_access; | |
80 ngx_uint_t last, bind_all, done; | 81 ngx_uint_t last, bind_all, done; |
81 ngx_conf_t pcf; | 82 ngx_conf_t pcf; |
82 ngx_array_t headers_in, in_ports; | 83 ngx_array_t headers_in, in_ports; |
83 ngx_hash_key_t *hk; | 84 ngx_hash_key_t *hk; |
84 ngx_hash_init_t hash; | 85 ngx_hash_init_t hash; |
91 ngx_http_conf_ctx_t *ctx; | 92 ngx_http_conf_ctx_t *ctx; |
92 ngx_http_conf_in_port_t *in_port; | 93 ngx_http_conf_in_port_t *in_port; |
93 ngx_http_conf_in_addr_t *in_addr; | 94 ngx_http_conf_in_addr_t *in_addr; |
94 ngx_hash_keys_arrays_t ha; | 95 ngx_hash_keys_arrays_t ha; |
95 ngx_http_server_name_t *name; | 96 ngx_http_server_name_t *name; |
97 ngx_http_phase_handler_t *ph; | |
96 ngx_http_virtual_names_t *vn; | 98 ngx_http_virtual_names_t *vn; |
97 ngx_http_core_srv_conf_t **cscfp, *cscf; | 99 ngx_http_core_srv_conf_t **cscfp, *cscf; |
98 ngx_http_core_loc_conf_t *clcf; | 100 ngx_http_core_loc_conf_t *clcf; |
101 ngx_http_phase_handler_pt checker; | |
99 ngx_http_core_main_conf_t *cmcf; | 102 ngx_http_core_main_conf_t *cmcf; |
100 #if (NGX_WIN32) | 103 #if (NGX_WIN32) |
101 ngx_iocp_conf_t *iocpcf; | 104 ngx_iocp_conf_t *iocpcf; |
102 #endif | 105 #endif |
103 | 106 |
291 != NGX_OK) | 294 != NGX_OK) |
292 { | 295 { |
293 return NGX_CONF_ERROR; | 296 return NGX_CONF_ERROR; |
294 } | 297 } |
295 | 298 |
296 cmcf->phases[NGX_HTTP_POST_READ_PHASE].type = NGX_OK; | |
297 | |
298 | 299 |
299 if (ngx_array_init(&cmcf->phases[NGX_HTTP_SERVER_REWRITE_PHASE].handlers, | 300 if (ngx_array_init(&cmcf->phases[NGX_HTTP_SERVER_REWRITE_PHASE].handlers, |
300 cf->pool, 1, sizeof(ngx_http_handler_pt)) | 301 cf->pool, 1, sizeof(ngx_http_handler_pt)) |
301 != NGX_OK) | 302 != NGX_OK) |
302 { | 303 { |
303 return NGX_CONF_ERROR; | 304 return NGX_CONF_ERROR; |
304 } | 305 } |
305 | 306 |
306 cmcf->phases[NGX_HTTP_SERVER_REWRITE_PHASE].type = NGX_OK; | |
307 | |
308 | |
309 /* the special find config phase for a single handler */ | |
310 | |
311 if (ngx_array_init(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers, | |
312 cf->pool, 1, sizeof(ngx_http_handler_pt)) | |
313 != NGX_OK) | |
314 { | |
315 return NGX_CONF_ERROR; | |
316 } | |
317 | |
318 cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].type = NGX_OK; | |
319 | |
320 h = ngx_array_push(&cmcf->phases[NGX_HTTP_FIND_CONFIG_PHASE].handlers); | |
321 if (h == NULL) { | |
322 return NGX_CONF_ERROR; | |
323 } | |
324 | |
325 *h = ngx_http_find_location_config; | |
326 | |
327 | 307 |
328 if (ngx_array_init(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers, | 308 if (ngx_array_init(&cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers, |
329 cf->pool, 1, sizeof(ngx_http_handler_pt)) | 309 cf->pool, 1, sizeof(ngx_http_handler_pt)) |
330 != NGX_OK) | 310 != NGX_OK) |
331 { | 311 { |
332 return NGX_CONF_ERROR; | 312 return NGX_CONF_ERROR; |
333 } | 313 } |
334 | 314 |
335 cmcf->phases[NGX_HTTP_REWRITE_PHASE].type = NGX_OK; | |
336 | |
337 | 315 |
338 if (ngx_array_init(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers, | 316 if (ngx_array_init(&cmcf->phases[NGX_HTTP_PREACCESS_PHASE].handlers, |
339 cf->pool, 1, sizeof(ngx_http_handler_pt)) | 317 cf->pool, 1, sizeof(ngx_http_handler_pt)) |
340 != NGX_OK) | 318 != NGX_OK) |
341 { | 319 { |
342 return NGX_CONF_ERROR; | 320 return NGX_CONF_ERROR; |
343 } | 321 } |
344 | 322 |
345 cmcf->phases[NGX_HTTP_PREACCESS_PHASE].type = NGX_OK; | |
346 | |
347 | 323 |
348 if (ngx_array_init(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers, | 324 if (ngx_array_init(&cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers, |
349 cf->pool, 2, sizeof(ngx_http_handler_pt)) | 325 cf->pool, 2, sizeof(ngx_http_handler_pt)) |
350 != NGX_OK) | 326 != NGX_OK) |
351 { | 327 { |
352 return NGX_CONF_ERROR; | 328 return NGX_CONF_ERROR; |
353 } | 329 } |
354 | 330 |
355 cmcf->phases[NGX_HTTP_ACCESS_PHASE].type = NGX_DECLINED; | |
356 | |
357 | 331 |
358 if (ngx_array_init(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers, | 332 if (ngx_array_init(&cmcf->phases[NGX_HTTP_CONTENT_PHASE].handlers, |
359 cf->pool, 4, sizeof(ngx_http_handler_pt)) | 333 cf->pool, 4, sizeof(ngx_http_handler_pt)) |
360 != NGX_OK) | 334 != NGX_OK) |
361 { | 335 { |
362 return NGX_CONF_ERROR; | 336 return NGX_CONF_ERROR; |
363 } | 337 } |
364 | 338 |
365 cmcf->phases[NGX_HTTP_CONTENT_PHASE].type = NGX_OK; | |
366 | |
367 | 339 |
368 if (ngx_array_init(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers, | 340 if (ngx_array_init(&cmcf->phases[NGX_HTTP_LOG_PHASE].handlers, |
369 cf->pool, 1, sizeof(ngx_http_handler_pt)) | 341 cf->pool, 1, sizeof(ngx_http_handler_pt)) |
370 != NGX_OK) | 342 != NGX_OK) |
371 { | 343 { |
372 return NGX_CONF_ERROR; | 344 return NGX_CONF_ERROR; |
373 } | 345 } |
374 | |
375 cmcf->phases[NGX_HTTP_LOG_PHASE].type = NGX_OK; | |
376 | 346 |
377 | 347 |
378 if (ngx_array_init(&headers_in, cf->temp_pool, 32, sizeof(ngx_hash_key_t)) | 348 if (ngx_array_init(&headers_in, cf->temp_pool, 32, sizeof(ngx_hash_key_t)) |
379 != NGX_OK) | 349 != NGX_OK) |
380 { | 350 { |
428 * http{}'s cf->ctx was needed while the configuration merging | 398 * http{}'s cf->ctx was needed while the configuration merging |
429 * and in postconfiguration process | 399 * and in postconfiguration process |
430 */ | 400 */ |
431 | 401 |
432 *cf = pcf; | 402 *cf = pcf; |
403 | |
404 | |
405 cmcf->phase_engine.server_rewrite_index = (ngx_uint_t) -1; | |
406 find_config_index = 0; | |
407 use_rewrite = cmcf->phases[NGX_HTTP_REWRITE_PHASE].handlers.nelts ? 1 : 0; | |
408 use_access = cmcf->phases[NGX_HTTP_ACCESS_PHASE].handlers.nelts ? 1 : 0; | |
409 | |
410 n = use_rewrite + use_access + 1; /* find config phase */ | |
411 | |
412 for (i = 0; i < NGX_HTTP_LOG_PHASE; i++) { | |
413 n += cmcf->phases[i].handlers.nelts; | |
414 } | |
415 | |
416 ph = ngx_pcalloc(cf->pool, | |
417 n * sizeof(ngx_http_phase_handler_t) + sizeof(void *)); | |
418 if (ph == NULL) { | |
419 return NGX_CONF_ERROR; | |
420 } | |
421 | |
422 cmcf->phase_engine.handlers = ph; | |
423 n = 0; | |
424 | |
425 for (i = 0; i < NGX_HTTP_LOG_PHASE; i++) { | |
426 h = cmcf->phases[i].handlers.elts; | |
427 | |
428 switch (i) { | |
429 | |
430 case NGX_HTTP_SERVER_REWRITE_PHASE: | |
431 if (cmcf->phase_engine.server_rewrite_index == (ngx_uint_t) -1) { | |
432 cmcf->phase_engine.server_rewrite_index = n; | |
433 } | |
434 checker = ngx_http_core_generic_phase; | |
435 | |
436 break; | |
437 | |
438 case NGX_HTTP_FIND_CONFIG_PHASE: | |
439 find_config_index = n; | |
440 | |
441 ph->checker = ngx_http_core_find_config_phase; | |
442 n++; | |
443 ph++; | |
444 | |
445 continue; | |
446 | |
447 case NGX_HTTP_POST_REWRITE_PHASE: | |
448 if (use_rewrite) { | |
449 ph->checker = ngx_http_core_post_rewrite_phase; | |
450 ph->next = find_config_index; | |
451 n++; | |
452 ph++; | |
453 } | |
454 | |
455 continue; | |
456 | |
457 case NGX_HTTP_ACCESS_PHASE: | |
458 checker = ngx_http_core_access_phase; | |
459 n++; | |
460 break; | |
461 | |
462 case NGX_HTTP_POST_ACCESS_PHASE: | |
463 if (use_access) { | |
464 ph->checker = ngx_http_core_post_access_phase; | |
465 ph->next = n; | |
466 ph++; | |
467 } | |
468 | |
469 continue; | |
470 | |
471 case NGX_HTTP_CONTENT_PHASE: | |
472 checker = ngx_http_core_content_phase; | |
473 break; | |
474 | |
475 default: | |
476 checker = ngx_http_core_generic_phase; | |
477 } | |
478 | |
479 n += cmcf->phases[i].handlers.nelts; | |
480 | |
481 for (j = cmcf->phases[i].handlers.nelts - 1; j >=0; j--) { | |
482 ph->checker = checker; | |
483 ph->handler = h[j]; | |
484 ph->next = n; | |
485 ph++; | |
486 } | |
487 } | |
433 | 488 |
434 | 489 |
435 /* | 490 /* |
436 * create the lists of ports, addresses and server names | 491 * create the lists of ports, addresses and server names |
437 * to quickly find the server core module configuration at run-time | 492 * to quickly find the server core module configuration at run-time |
934 | 989 |
935 name = ngx_array_push(&in_addr->names); | 990 name = ngx_array_push(&in_addr->names); |
936 if (name == NULL) { | 991 if (name == NULL) { |
937 return NGX_ERROR; | 992 return NGX_ERROR; |
938 } | 993 } |
939 server_names = cscf->server_names.elts; | |
940 | 994 |
941 *name = server_names[i]; | 995 *name = server_names[i]; |
942 } | 996 } |
943 | 997 |
944 return NGX_OK; | 998 return NGX_OK; |