summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_router.c
diff options
context:
space:
mode:
authorValentin Bartenev <vbart@nginx.com>2019-02-27 17:25:07 +0300
committerValentin Bartenev <vbart@nginx.com>2019-02-27 17:25:07 +0300
commite929d08201aae949db25ae8c1051a91e96ba3011 (patch)
tree76af15b49cb67547dbd1942466a6bb360459fc6b /src/nxt_router.c
parenta881c31abdb9fda2ba0d2e05c45c2ce890a6cfab (diff)
downloadunit-e929d08201aae949db25ae8c1051a91e96ba3011.tar.gz
unit-e929d08201aae949db25ae8c1051a91e96ba3011.tar.bz2
Fixed processing of SERVER_NAME after 77aad2c142a0.
Previously, the nxt_router_prepare_msg() function expected server host among other headers unmodified. It's not true anymore since normalization of the Host header has been introduced in 77aad2c142a0. The nxt_unit_split_host() function was removed. It didn't work correctly with IPv6 literals. Anyway, after 77aad2c142a0 the port splitting is done in router while Host header processing.
Diffstat (limited to 'src/nxt_router.c')
-rw-r--r--src/nxt_router.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/src/nxt_router.c b/src/nxt_router.c
index e81a2f96..7cd28416 100644
--- a/src/nxt_router.c
+++ b/src/nxt_router.c
@@ -4662,12 +4662,13 @@ nxt_router_prepare_msg(nxt_task_t *task, nxt_app_request_t *r,
h = &r->header;
req_size = sizeof(nxt_unit_request_t)
- + h->method.length + 1
- + h->version.length + 1
- + r->remote.length + 1
- + r->local.length + 1
- + h->target.length + 1
- + (h->path.start != h->target.start ? h->path.length + 1 : 0);
+ + h->method.length + 1
+ + h->version.length + 1
+ + r->remote.length + 1
+ + r->local.length + 1
+ + h->server_name.length + 1
+ + h->target.length + 1
+ + (h->path.start != h->target.start ? h->path.length + 1 : 0);
fields_count = 0;
@@ -4722,6 +4723,11 @@ nxt_router_prepare_msg(nxt_task_t *task, nxt_app_request_t *r,
p = nxt_cpymem(p, r->local.start, r->local.length);
*p++ = '\0';
+ req->server_name_length = h->server_name.length;
+ nxt_unit_sptr_set(&req->server_name, p);
+ p = nxt_cpymem(p, h->server_name.start, h->server_name.length);
+ *p++ = '\0';
+
target_pos = p;
req->target_length = h->target.length;
nxt_unit_sptr_set(&req->target, p);
@@ -4749,7 +4755,6 @@ nxt_router_prepare_msg(nxt_task_t *task, nxt_app_request_t *r,
req->query.offset = 0;
}
- req->host_field = NXT_UNIT_NONE_FIELD;
req->content_length_field = NXT_UNIT_NONE_FIELD;
req->content_type_field = NXT_UNIT_NONE_FIELD;
req->cookie_field = NXT_UNIT_NONE_FIELD;
@@ -4769,10 +4774,7 @@ nxt_router_prepare_msg(nxt_task_t *task, nxt_app_request_t *r,
dst_field->name_length = field->name_length + prefix->length;
dst_field->value_length = field->value_length;
- if (field->value == h->host.start) {
- req->host_field = dst_field - req->fields;
-
- } else if (field->value == h->content_length.start) {
+ if (field->value == h->content_length.start) {
req->content_length_field = dst_field - req->fields;
} else if (field->value == h->content_type.start) {