Mercurial > hg > nginx
comparison src/http/modules/ngx_http_proxy_module.c @ 1671:8075179cae21
ngx_parse_url() saves port text, this allows to use it in proxy host header
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 28 Nov 2007 19:55:31 +0000 |
parents | e9bd042134cb |
children | ca317d9b5c09 |
comparison
equal
deleted
inserted
replaced
1670:ab6a0d0cf68b | 1671:8075179cae21 |
---|---|
2643 | 2643 |
2644 static ngx_int_t | 2644 static ngx_int_t |
2645 ngx_http_proxy_set_vars(ngx_pool_t *pool, ngx_url_t *u, | 2645 ngx_http_proxy_set_vars(ngx_pool_t *pool, ngx_url_t *u, |
2646 ngx_http_proxy_vars_t *v) | 2646 ngx_http_proxy_vars_t *v) |
2647 { | 2647 { |
2648 u_char *p; | |
2649 | |
2650 if (!u->unix_socket) { | 2648 if (!u->unix_socket) { |
2651 if (u->no_port || u->port == u->default_port) { | 2649 if (u->no_port || u->port == u->default_port) { |
2652 v->host_header = u->host; | 2650 v->host_header = u->host; |
2653 | 2651 |
2654 if (u->default_port == 80) { | 2652 if (u->default_port == 80) { |
2659 v->port.len = sizeof("443") - 1; | 2657 v->port.len = sizeof("443") - 1; |
2660 v->port.data = (u_char *) "443"; | 2658 v->port.data = (u_char *) "443"; |
2661 } | 2659 } |
2662 | 2660 |
2663 } else { | 2661 } else { |
2664 p = ngx_palloc(pool, u->host.len + sizeof(":65536") - 1); | 2662 v->host_header.len = u->host.len + 1 + u->port_text.len; |
2665 if (p == NULL) { | 2663 v->host_header.data = u->host.data; |
2666 return NGX_ERROR; | 2664 v->port = u->port_text; |
2667 } | |
2668 | |
2669 v->host_header.len = ngx_sprintf(p, "%V:%d", &u->host, u->port) - p; | |
2670 v->host_header.data = p; | |
2671 | |
2672 v->port.len = v->host_header.len - u->host.len - 1; | |
2673 v->port.data = p + u->host.len + 1; | |
2674 } | 2665 } |
2675 | 2666 |
2676 } else { | 2667 } else { |
2677 v->host_header.len = sizeof("localhost") - 1; | 2668 v->host_header.len = sizeof("localhost") - 1; |
2678 v->host_header.data = (u_char *) "localhost"; | 2669 v->host_header.data = (u_char *) "localhost"; |