comparison src/http/ngx_http_core_module.c @ 48:6cfc63e68377 NGINX_0_1_24

nginx 0.1.24 *) Feature: the ngx_http_ssi_filter_module supports the QUERY_STRING and DOCUMENT_URI variables. *) Bugfix: the ngx_http_autoindex_module may some times return the 404 response for existent directory, if this directory was used in "alias" directive. *) Bugfix: the ngx_http_ssi_filter_module ran incorrectly for large responses. *) Bugfix: the lack of the "Referer" header line was always accounted as valid referrer.
author Igor Sysoev <http://sysoev.ru>
date Fri, 04 Mar 2005 00:00:00 +0300
parents 2879cd3a40cb
children 72eb30262aac
comparison
equal deleted inserted replaced
47:4ae32548452c 48:6cfc63e68377
53 void *conf); 53 void *conf);
54 static char *ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd, 54 static char *ngx_http_core_keepalive(ngx_conf_t *cf, ngx_command_t *cmd,
55 void *conf); 55 void *conf);
56 56
57 static char *ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data); 57 static char *ngx_http_core_lowat_check(ngx_conf_t *cf, void *post, void *data);
58 static ngx_int_t ngx_http_core_init(ngx_cycle_t *cycle);
58 59
59 static ngx_conf_post_t ngx_http_core_lowat_post = 60 static ngx_conf_post_t ngx_http_core_lowat_post =
60 { ngx_http_core_lowat_check }; 61 { ngx_http_core_lowat_check };
61 62
62 63
353 ngx_module_t ngx_http_core_module = { 354 ngx_module_t ngx_http_core_module = {
354 NGX_MODULE, 355 NGX_MODULE,
355 &ngx_http_core_module_ctx, /* module context */ 356 &ngx_http_core_module_ctx, /* module context */
356 ngx_http_core_commands, /* module directives */ 357 ngx_http_core_commands, /* module directives */
357 NGX_HTTP_MODULE, /* module type */ 358 NGX_HTTP_MODULE, /* module type */
358 NULL, /* init module */ 359 ngx_http_core_init, /* init module */
359 NULL /* init process */ 360 NULL /* init process */
360 }; 361 };
361 362
362 363
363 void 364 void
980 "http reset delay"); 981 "http reset delay");
981 return NGX_DECLINED; 982 return NGX_DECLINED;
982 } 983 }
983 984
984 #endif 985 #endif
985
986
987 ngx_http_variable_t *
988 ngx_http_add_variable(ngx_conf_t *cf)
989 {
990 ngx_http_variable_t *var;
991 ngx_http_core_main_conf_t *cmcf;
992
993 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
994
995 if (cmcf->variables.elts == NULL) {
996 if (ngx_array_init(&cmcf->variables, cf->pool, 5,
997 sizeof(ngx_http_variable_t)) == NGX_ERROR)
998 {
999 return NULL;
1000 }
1001 }
1002
1003 if (!(var = ngx_array_push(&cmcf->variables))) {
1004 return NULL;
1005 }
1006
1007 var->index = cmcf->variables.nelts - 1;
1008
1009 return var;
1010 }
1011
1012
1013 ngx_http_variable_value_t *
1014 ngx_http_get_variable(ngx_http_request_t *r, ngx_uint_t index)
1015 {
1016 ngx_http_variable_t *v;
1017 ngx_http_core_main_conf_t *cmcf;
1018
1019 /* TODO: cached variables */
1020
1021 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
1022
1023 if (cmcf->variables.elts == NULL || cmcf->variables.nelts <= index) {
1024 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
1025 "unknown variable index: %d", index);
1026 return NULL;
1027 }
1028
1029 v = cmcf->variables.elts;
1030
1031 return v[index].handler(r, v[index].data);
1032 }
1033 986
1034 987
1035 static char * 988 static char *
1036 ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy) 989 ngx_http_core_server(ngx_conf_t *cf, ngx_command_t *cmd, void *dummy)
1037 { 990 {
1379 if (lcf->types == NULL) { 1332 if (lcf->types == NULL) {
1380 return NGX_CONF_ERROR; 1333 return NGX_CONF_ERROR;
1381 } 1334 }
1382 1335
1383 for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) { 1336 for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) {
1384 if (ngx_array_init(&lcf->types[i], cf->pool, 5, 1337 if (ngx_array_init(&lcf->types[i], cf->pool, 4,
1385 sizeof(ngx_http_type_t)) == NGX_ERROR) 1338 sizeof(ngx_http_type_t)) == NGX_ERROR)
1386 { 1339 {
1387 return NGX_CONF_ERROR; 1340 return NGX_CONF_ERROR;
1388 } 1341 }
1389 } 1342 }
1413 1366
1414 if (!(cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_main_conf_t)))) { 1367 if (!(cmcf = ngx_pcalloc(cf->pool, sizeof(ngx_http_core_main_conf_t)))) {
1415 return NGX_CONF_ERROR; 1368 return NGX_CONF_ERROR;
1416 } 1369 }
1417 1370
1418 if (ngx_array_init(&cmcf->servers, cf->pool, 5, 1371 if (ngx_array_init(&cmcf->servers, cf->pool, 4,
1419 sizeof(ngx_http_core_srv_conf_t *)) == NGX_ERROR) 1372 sizeof(ngx_http_core_srv_conf_t *)) == NGX_ERROR)
1420 { 1373 {
1421 return NGX_CONF_ERROR; 1374 return NGX_CONF_ERROR;
1422 } 1375 }
1423 1376
1458 * set by ngx_pcalloc(): 1411 * set by ngx_pcalloc():
1459 * 1412 *
1460 * conf->client_large_buffers.num = 0; 1413 * conf->client_large_buffers.num = 0;
1461 */ 1414 */
1462 1415
1463 if (ngx_array_init(&cscf->locations, cf->pool, 5, sizeof(void *)) 1416 if (ngx_array_init(&cscf->locations, cf->pool, 4, sizeof(void *))
1464 == NGX_ERROR) 1417 == NGX_ERROR)
1465 { 1418 {
1466 return NGX_CONF_ERROR; 1419 return NGX_CONF_ERROR;
1467 } 1420 }
1468 1421
1469 if (ngx_array_init(&cscf->listen, cf->pool, 5, sizeof(ngx_http_listen_t)) 1422 if (ngx_array_init(&cscf->listen, cf->pool, 4, sizeof(ngx_http_listen_t))
1470 == NGX_ERROR) 1423 == NGX_ERROR)
1471 { 1424 {
1472 return NGX_CONF_ERROR; 1425 return NGX_CONF_ERROR;
1473 } 1426 }
1474 1427
1475 if (ngx_array_init(&cscf->server_names, cf->pool, 5, 1428 if (ngx_array_init(&cscf->server_names, cf->pool, 4,
1476 sizeof(ngx_http_server_name_t)) == NGX_ERROR) 1429 sizeof(ngx_http_server_name_t)) == NGX_ERROR)
1477 { 1430 {
1478 return NGX_CONF_ERROR; 1431 return NGX_CONF_ERROR;
1479 } 1432 }
1480 1433
1652 if (conf->types == NULL) { 1605 if (conf->types == NULL) {
1653 return NGX_CONF_ERROR; 1606 return NGX_CONF_ERROR;
1654 } 1607 }
1655 1608
1656 for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) { 1609 for (i = 0; i < NGX_HTTP_TYPES_HASH_PRIME; i++) {
1657 if (ngx_array_init(&conf->types[i], cf->pool, 5, 1610 if (ngx_array_init(&conf->types[i], cf->pool, 4,
1658 sizeof(ngx_http_type_t)) == NGX_ERROR) 1611 sizeof(ngx_http_type_t)) == NGX_ERROR)
1659 { 1612 {
1660 return NGX_CONF_ERROR; 1613 return NGX_CONF_ERROR;
1661 } 1614 }
1662 } 1615 }
2061 2014
2062 #endif 2015 #endif
2063 2016
2064 return NGX_CONF_OK; 2017 return NGX_CONF_OK;
2065 } 2018 }
2019
2020
2021 static ngx_int_t
2022 ngx_http_core_init(ngx_cycle_t *cycle)
2023 {
2024 return ngx_http_core_variables_init(cycle);
2025 }