Mercurial > hg > nginx-vendor-0-8
diff src/http/ngx_http_variables.c @ 376:edf1cb6c328e NGINX_0_7_0
nginx 0.7.0
*) 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: a segmentation fault might occur in worker process on Linux,
if keepalive was enabled.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 19 May 2008 00:00:00 +0400 |
parents | 54fad6c4b555 |
children | 984bb0b1399b |
line wrap: on
line diff
--- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -75,6 +75,8 @@ static ngx_int_t ngx_http_variable_sent_ static ngx_int_t ngx_http_variable_nginx_version(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_variable_hostname(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); /* * TODO: @@ -221,6 +223,9 @@ static ngx_http_variable_t ngx_http_cor { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version, 0, 0, 0 }, + { ngx_string("hostname"), NULL, ngx_http_variable_hostname, + 0, 0, 0 }, + { ngx_null_string, NULL, NULL, 0, 0, 0 } }; @@ -712,26 +717,15 @@ ngx_http_variable_host(ngx_http_request_ { ngx_http_core_srv_conf_t *cscf; - if (r->host_start == NULL) { - - if (r->headers_in.host) { - v->len = r->headers_in.host_name_len; - v->data = r->headers_in.host->value.data; - - } else { - cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); - - v->len = cscf->server_name.len; - v->data = cscf->server_name.data; - } - - } else if (r->host_end) { - v->len = r->host_end - r->host_start; - v->data = r->host_start; + if (r->headers_in.server.len) { + v->len = r->headers_in.server.len; + v->data = r->headers_in.server.data; } else { - v->not_found = 1; - return NGX_OK; + cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); + + v->len = cscf->server_name.len; + v->data = cscf->server_name.data; } v->valid = 1; @@ -1283,6 +1277,20 @@ ngx_http_variable_nginx_version(ngx_http } +static ngx_int_t +ngx_http_variable_hostname(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + v->len = ngx_cycle->hostname.len; + v->valid = 1; + v->no_cacheable = 0; + v->not_found = 0; + v->data = ngx_cycle->hostname.data; + + return NGX_OK; +} + + ngx_int_t ngx_http_variables_add_core_vars(ngx_conf_t *cf) {