aboutsummaryrefslogtreecommitdiff
path: root/src/http/ngx_http_variables.c
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2008-05-16 14:39:06 +0000
committerIgor Sysoev <igor@sysoev.ru>2008-05-16 14:39:06 +0000
commit3be5257a4f8e6e0fd5d058a314adbe5b7f5b9dd7 (patch)
treeeb8ec2fe0dc4f288caa29e991318cbd9bc21e36b /src/http/ngx_http_variables.c
parent76566f88d9984cc870aa6ccb4eca64ef43ff40d2 (diff)
downloadnginx-3be5257a4f8e6e0fd5d058a314adbe5b7f5b9dd7.tar.gz
nginx-3be5257a4f8e6e0fd5d058a314adbe5b7f5b9dd7.zip
$hostname variable
Diffstat (limited to 'src/http/ngx_http_variables.c')
-rw-r--r--src/http/ngx_http_variables.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c
index c2a27a76a..16f092305 100644
--- 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_transfer_encoding(ngx_http_request_t *r,
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_core_variables[] = {
{ 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 @@ ngx_http_variable_nginx_version(ngx_http_request_t *r,
}
+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)
{