comparison src/http/ngx_http_variables.c @ 376:d13234035cad NGINX_0_6_32

nginx 0.6.32 *) Change: the "none" parameter in the "ssl_session_cache" directive; now this is default parameter. Thanks to Rob Mueller. *) Change: now the 0x00-0x1F, '"' and '\' characters are escaped as \xXX in an access_log. Thanks to Maxim Dounin. *) Change: now nginx allows several "Host" request header line. *) Feature: the "modified" flag in the "expires" directive. *) Feature: the $uid_got and $uid_set variables may be used at any request processing stage. *) Feature: the $hostname variable. Thanks to Andrei Nigmatulin. *) Feature: DESTDIR support. Thanks to Todd A. Fisher and Andras Voroskoi. *) Bugfix: if sub_filter and SSI were used together, then responses might were transferred incorrectly. *) Bugfix: large SSI inclusions might be truncated. *) Bugfix: the "proxy_pass" directive did not work with the HTTPS protocol; the bug had appeared in 0.6.9. *) Bugfix: worker processes might not catch reconfiguration and log rotation signals. *) Bugfix: nginx could not be built on latest Fedora 9 Linux. Thanks to Roxis. *) Bugfix: a segmentation fault might occur in worker process on Linux, if keepalive was enabled.
author Igor Sysoev <http://sysoev.ru>
date Mon, 07 Jul 2008 00:00:00 +0400
parents 54fad6c4b555
children 09b703ae3ba5
comparison
equal deleted inserted replaced
375:52f3c9c7eff0 376:d13234035cad
72 ngx_http_variable_value_t *v, uintptr_t data); 72 ngx_http_variable_value_t *v, uintptr_t data);
73 static ngx_int_t ngx_http_variable_sent_transfer_encoding(ngx_http_request_t *r, 73 static ngx_int_t ngx_http_variable_sent_transfer_encoding(ngx_http_request_t *r,
74 ngx_http_variable_value_t *v, uintptr_t data); 74 ngx_http_variable_value_t *v, uintptr_t data);
75 75
76 static ngx_int_t ngx_http_variable_nginx_version(ngx_http_request_t *r, 76 static ngx_int_t ngx_http_variable_nginx_version(ngx_http_request_t *r,
77 ngx_http_variable_value_t *v, uintptr_t data);
78 static ngx_int_t ngx_http_variable_hostname(ngx_http_request_t *r,
77 ngx_http_variable_value_t *v, uintptr_t data); 79 ngx_http_variable_value_t *v, uintptr_t data);
78 80
79 /* 81 /*
80 * TODO: 82 * TODO:
81 * Apache CGI: AUTH_TYPE, PATH_INFO (null), PATH_TRANSLATED 83 * Apache CGI: AUTH_TYPE, PATH_INFO (null), PATH_TRANSLATED
219 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 }, 221 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
220 222
221 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version, 223 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version,
222 0, 0, 0 }, 224 0, 0, 0 },
223 225
226 { ngx_string("hostname"), NULL, ngx_http_variable_hostname,
227 0, 0, 0 },
228
224 { ngx_null_string, NULL, NULL, 0, 0, 0 } 229 { ngx_null_string, NULL, NULL, 0, 0, 0 }
225 }; 230 };
226 231
227 232
228 ngx_http_variable_value_t ngx_http_variable_null_value = 233 ngx_http_variable_value_t ngx_http_variable_null_value =
710 ngx_http_variable_host(ngx_http_request_t *r, ngx_http_variable_value_t *v, 715 ngx_http_variable_host(ngx_http_request_t *r, ngx_http_variable_value_t *v,
711 uintptr_t data) 716 uintptr_t data)
712 { 717 {
713 ngx_http_core_srv_conf_t *cscf; 718 ngx_http_core_srv_conf_t *cscf;
714 719
715 if (r->host_start == NULL) { 720 if (r->headers_in.server.len) {
716 721 v->len = r->headers_in.server.len;
717 if (r->headers_in.host) { 722 v->data = r->headers_in.server.data;
718 v->len = r->headers_in.host_name_len;
719 v->data = r->headers_in.host->value.data;
720
721 } else {
722 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
723
724 v->len = cscf->server_name.len;
725 v->data = cscf->server_name.data;
726 }
727
728 } else if (r->host_end) {
729 v->len = r->host_end - r->host_start;
730 v->data = r->host_start;
731 723
732 } else { 724 } else {
733 v->not_found = 1; 725 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
734 return NGX_OK; 726
727 v->len = cscf->server_name.len;
728 v->data = cscf->server_name.data;
735 } 729 }
736 730
737 v->valid = 1; 731 v->valid = 1;
738 v->no_cacheable = 0; 732 v->no_cacheable = 0;
739 v->not_found = 0; 733 v->not_found = 0;
1276 v->len = sizeof(NGINX_VERSION) - 1; 1270 v->len = sizeof(NGINX_VERSION) - 1;
1277 v->valid = 1; 1271 v->valid = 1;
1278 v->no_cacheable = 0; 1272 v->no_cacheable = 0;
1279 v->not_found = 0; 1273 v->not_found = 0;
1280 v->data = (u_char *) NGINX_VERSION; 1274 v->data = (u_char *) NGINX_VERSION;
1275
1276 return NGX_OK;
1277 }
1278
1279
1280 static ngx_int_t
1281 ngx_http_variable_hostname(ngx_http_request_t *r,
1282 ngx_http_variable_value_t *v, uintptr_t data)
1283 {
1284 v->len = ngx_cycle->hostname.len;
1285 v->valid = 1;
1286 v->no_cacheable = 0;
1287 v->not_found = 0;
1288 v->data = ngx_cycle->hostname.data;
1281 1289
1282 return NGX_OK; 1290 return NGX_OK;
1283 } 1291 }
1284 1292
1285 1293