Mercurial > hg > nginx
diff src/http/ngx_http_variables.c @ 2011:b56d4b1ebac7
$hostname variable
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Fri, 16 May 2008 14:39:06 +0000 |
parents | b9de93d804ea |
children | 2a92804f4109 8e4450668968 |
line wrap: on
line diff
--- a/src/http/ngx_http_variables.c Fri May 16 14:32:58 2008 +0000 +++ b/src/http/ngx_http_variables.c Fri May 16 14:39:06 2008 +0000 @@ -75,6 +75,8 @@ 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 @@ { 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 } }; @@ -1272,6 +1277,20 @@ } +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) {