mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
axe useless r->server_name
This commit is contained in:
parent
cc5956772b
commit
feee7265b5
@ -1780,7 +1780,6 @@ ngx_http_subrequest(ngx_http_request_t *r,
|
||||
sr->in_addr = r->in_addr;
|
||||
sr->port = r->port;
|
||||
sr->port_text = r->port_text;
|
||||
sr->server_name = r->server_name;
|
||||
|
||||
sr->variables = r->variables;
|
||||
|
||||
|
@ -160,6 +160,7 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
||||
ngx_list_part_t *part;
|
||||
ngx_table_elt_t *header;
|
||||
ngx_http_core_loc_conf_t *clcf;
|
||||
ngx_http_core_srv_conf_t *cscf;
|
||||
/* AF_INET only */
|
||||
u_char addr[INET_ADDRSTRLEN];
|
||||
|
||||
@ -282,7 +283,8 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
||||
r->headers_out.location->hash = 0;
|
||||
|
||||
if (clcf->server_name_in_redirect) {
|
||||
host = r->server_name;
|
||||
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
|
||||
host = cscf->server_name;
|
||||
|
||||
} else if (r->headers_in.host) {
|
||||
host.len = r->headers_in.host_name_len;
|
||||
|
@ -340,8 +340,6 @@ ngx_http_init_request(ngx_event_t *rev)
|
||||
r->srv_conf = cscf->ctx->srv_conf;
|
||||
r->loc_conf = cscf->ctx->loc_conf;
|
||||
|
||||
r->server_name = cscf->server_name;
|
||||
|
||||
rev->handler = ngx_http_process_request_line;
|
||||
|
||||
#if (NGX_HTTP_SSL)
|
||||
@ -1512,9 +1510,6 @@ ngx_http_find_virtual_server(ngx_http_request_t *r, u_char *host, size_t len,
|
||||
|
||||
found:
|
||||
|
||||
r->server_name.len = len;
|
||||
r->server_name.data = host;
|
||||
|
||||
r->srv_conf = cscf->ctx->srv_conf;
|
||||
r->loc_conf = cscf->ctx->loc_conf;
|
||||
|
||||
@ -2605,15 +2600,16 @@ static u_char *
|
||||
ngx_http_log_error_handler(ngx_http_request_t *r, ngx_http_request_t *sr,
|
||||
u_char *buf, size_t len)
|
||||
{
|
||||
char *uri_separator;
|
||||
u_char *p;
|
||||
ngx_http_upstream_t *u;
|
||||
char *uri_separator;
|
||||
u_char *p;
|
||||
ngx_http_upstream_t *u;
|
||||
ngx_http_core_srv_conf_t *cscf;
|
||||
|
||||
if (r->server_name.data) {
|
||||
p = ngx_snprintf(buf, len, ", server: %V", &r->server_name);
|
||||
len -= p - buf;
|
||||
buf = p;
|
||||
}
|
||||
cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
|
||||
|
||||
p = ngx_snprintf(buf, len, ", server: %V", &cscf->server_name);
|
||||
len -= p - buf;
|
||||
buf = p;
|
||||
|
||||
if (r->request_line.data == NULL && r->request_start) {
|
||||
for (p = r->request_start; p < r->header_in->last; p++) {
|
||||
|
@ -373,7 +373,6 @@ struct ngx_http_request_s {
|
||||
uint32_t in_addr;
|
||||
ngx_uint_t port;
|
||||
ngx_str_t *port_text; /* ":80" */
|
||||
ngx_str_t server_name;
|
||||
ngx_http_virtual_names_t *virtual_names;
|
||||
|
||||
ngx_int_t phase_handler;
|
||||
|
@ -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) {
|
||||
@ -956,6 +961,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)
|
||||
|
Loading…
Reference in New Issue
Block a user