Mercurial > hg > nginx-quic
diff src/http/ngx_http_variables.c @ 1811:0d9c6fe7502b
axe useless r->server_name
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 30 Dec 2007 08:15:27 +0000 |
parents | bb72f7518992 |
children | b9de93d804ea |
line wrap: on
line diff
--- 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_docum 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_cor 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_ 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_h 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) {