mirror of
https://github.com/nginx/nginx.git
synced 2025-02-25 18:55:26 -06:00
axe r->port
This commit is contained in:
parent
2d95c82f91
commit
80a4f29c8a
@ -2061,7 +2061,6 @@ ngx_http_subrequest(ngx_http_request_t *r,
|
|||||||
c->data = sr;
|
c->data = sr;
|
||||||
}
|
}
|
||||||
|
|
||||||
sr->port = r->port;
|
|
||||||
sr->port_text = r->port_text;
|
sr->port_text = r->port_text;
|
||||||
|
|
||||||
sr->variables = r->variables;
|
sr->variables = r->variables;
|
||||||
|
@ -155,12 +155,17 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
size_t len;
|
size_t len;
|
||||||
ngx_str_t host;
|
ngx_str_t host;
|
||||||
ngx_buf_t *b;
|
ngx_buf_t *b;
|
||||||
ngx_uint_t status, i;
|
ngx_uint_t status, i, port;
|
||||||
ngx_chain_t out;
|
ngx_chain_t out;
|
||||||
ngx_list_part_t *part;
|
ngx_list_part_t *part;
|
||||||
ngx_table_elt_t *header;
|
ngx_table_elt_t *header;
|
||||||
|
ngx_connection_t *c;
|
||||||
ngx_http_core_loc_conf_t *clcf;
|
ngx_http_core_loc_conf_t *clcf;
|
||||||
ngx_http_core_srv_conf_t *cscf;
|
ngx_http_core_srv_conf_t *cscf;
|
||||||
|
struct sockaddr_in *sin;
|
||||||
|
#if (NGX_HAVE_INET6)
|
||||||
|
struct sockaddr_in6 *sin6;
|
||||||
|
#endif
|
||||||
u_char addr[NGX_SOCKADDR_STRLEN];
|
u_char addr[NGX_SOCKADDR_STRLEN];
|
||||||
|
|
||||||
r->header_sent = 1;
|
r->header_sent = 1;
|
||||||
@ -297,13 +302,29 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
c = r->connection;
|
||||||
|
|
||||||
|
switch (c->local_sockaddr->sa_family) {
|
||||||
|
|
||||||
|
#if (NGX_HAVE_INET6)
|
||||||
|
case AF_INET6:
|
||||||
|
sin6 = (struct sockaddr_in6 *) c->local_sockaddr;
|
||||||
|
port = sin6->sin6_port;
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
default: /* AF_INET */
|
||||||
|
sin = (struct sockaddr_in *) c->local_sockaddr;
|
||||||
|
port = sin->sin_port;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
#if (NGX_HTTP_SSL)
|
#if (NGX_HTTP_SSL)
|
||||||
if (r->connection->ssl) {
|
if (r->connection->ssl) {
|
||||||
len += sizeof("Location: https://") - 1
|
len += sizeof("Location: https://") - 1
|
||||||
+ host.len
|
+ host.len
|
||||||
+ r->headers_out.location->value.len + 2;
|
+ r->headers_out.location->value.len + 2;
|
||||||
|
|
||||||
if (clcf->port_in_redirect && r->port != 443) {
|
if (clcf->port_in_redirect && port != 443) {
|
||||||
len += r->port_text->len;
|
len += r->port_text->len;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +335,7 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
+ host.len
|
+ host.len
|
||||||
+ r->headers_out.location->value.len + 2;
|
+ r->headers_out.location->value.len + 2;
|
||||||
|
|
||||||
if (clcf->port_in_redirect && r->port != 80) {
|
if (clcf->port_in_redirect && port != 80) {
|
||||||
len += r->port_text->len;
|
len += r->port_text->len;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,6 +343,7 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
} else {
|
} else {
|
||||||
host.len = 0;
|
host.len = 0;
|
||||||
host.data = NULL;
|
host.data = NULL;
|
||||||
|
port = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (r->chunked) {
|
if (r->chunked) {
|
||||||
@ -476,14 +498,14 @@ ngx_http_header_filter(ngx_http_request_t *r)
|
|||||||
if (clcf->port_in_redirect) {
|
if (clcf->port_in_redirect) {
|
||||||
#if (NGX_HTTP_SSL)
|
#if (NGX_HTTP_SSL)
|
||||||
if (r->connection->ssl) {
|
if (r->connection->ssl) {
|
||||||
if (r->port != 443) {
|
if (port != 443) {
|
||||||
b->last = ngx_copy(b->last, r->port_text->data,
|
b->last = ngx_copy(b->last, r->port_text->data,
|
||||||
r->port_text->len);
|
r->port_text->len);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if (r->port != 80) {
|
if (port != 80) {
|
||||||
b->last = ngx_copy(b->last, r->port_text->data,
|
b->last = ngx_copy(b->last, r->port_text->data,
|
||||||
r->port_text->len);
|
r->port_text->len);
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,6 @@ ngx_http_init_request(ngx_event_t *rev)
|
|||||||
|
|
||||||
port = c->listening->servers;
|
port = c->listening->servers;
|
||||||
|
|
||||||
r->port = port->port;
|
|
||||||
r->port_text = &port->port_text;
|
r->port_text = &port->port_text;
|
||||||
|
|
||||||
r->connection = c;
|
r->connection = c;
|
||||||
|
@ -384,7 +384,6 @@ struct ngx_http_request_s {
|
|||||||
ngx_http_post_subrequest_t *post_subrequest;
|
ngx_http_post_subrequest_t *post_subrequest;
|
||||||
ngx_http_posted_request_t *posted_requests;
|
ngx_http_posted_request_t *posted_requests;
|
||||||
|
|
||||||
ngx_uint_t port;
|
|
||||||
ngx_str_t *port_text; /* ":80" */
|
ngx_str_t *port_text; /* ":80" */
|
||||||
ngx_http_virtual_names_t *virtual_names;
|
ngx_http_virtual_names_t *virtual_names;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user