diff options
author | Igor Sysoev <igor@sysoev.ru> | 2007-12-30 08:15:27 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2007-12-30 08:15:27 +0000 |
commit | feee7265b5f531fb42cca762a3ac0ae765941504 (patch) | |
tree | d3e064e6dc9c6a22bf737d7b90599c98dfbe3efd /src/http/ngx_http_variables.c | |
parent | cc5956772bb28f1ca815d2636d44469ba00e687e (diff) | |
download | nginx-feee7265b5f531fb42cca762a3ac0ae765941504.tar.gz nginx-feee7265b5f531fb42cca762a3ac0ae765941504.zip |
axe useless r->server_name
Diffstat (limited to 'src/http/ngx_http_variables.c')
-rw-r--r-- | src/http/ngx_http_variables.c | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/src/http/ngx_http_variables.c b/src/http/ngx_http_variables.c index 971f70522..df00675eb 100644 --- a/src/http/ngx_http_variables.c +++ b/src/http/ngx_http_variables.c @@ -47,6 +47,8 @@ static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_request_filename(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); +static ngx_int_t ngx_http_variable_server_name(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_request_method(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data); static ngx_int_t ngx_http_variable_remote_user(ngx_http_request_t *r, @@ -172,8 +174,7 @@ static ngx_http_variable_t ngx_http_core_variables[] = { ngx_http_variable_request_filename, 0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, - { ngx_string("server_name"), NULL, ngx_http_variable_request, - offsetof(ngx_http_request_t, server_name), 0, 0 }, + { ngx_string("server_name"), NULL, ngx_http_variable_server_name, 0, 0, 0 }, { ngx_string("request_method"), NULL, ngx_http_variable_request_method, 0, 0, 0 }, @@ -709,6 +710,8 @@ static ngx_int_t ngx_http_variable_host(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { + ngx_http_core_srv_conf_t *cscf; + if (r->host_start == NULL) { if (r->headers_in.host) { @@ -716,8 +719,10 @@ ngx_http_variable_host(ngx_http_request_t *r, ngx_http_variable_value_t *v, v->data = r->headers_in.host->value.data; } else { - v->len = r->server_name.len; - v->data = r->server_name.data; + 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) { @@ -957,6 +962,24 @@ ngx_http_variable_request_filename(ngx_http_request_t *r, static ngx_int_t +ngx_http_variable_server_name(ngx_http_request_t *r, + ngx_http_variable_value_t *v, uintptr_t data) +{ + ngx_http_core_srv_conf_t *cscf; + + cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); + + v->len = cscf->server_name.len; + v->valid = 1; + v->no_cacheable = 0; + v->not_found = 0; + v->data = cscf->server_name.data; + + return NGX_OK; +} + + +static ngx_int_t ngx_http_variable_request_method(ngx_http_request_t *r, ngx_http_variable_value_t *v, uintptr_t data) { |