summaryrefslogtreecommitdiffhomepage
path: root/src/nxt_http_request.c
diff options
context:
space:
mode:
authorZhidao HONG <z.hong@f5.com>2022-06-20 13:16:25 +0800
committerZhidao HONG <z.hong@f5.com>2022-06-20 13:16:25 +0800
commit14dfa439eed1983693d7d128cc51c5e738a487d7 (patch)
tree771e4648406614b53c9195c4e66c78bf84520d27 /src/nxt_http_request.c
parentfd38e69c3db9cda55fb24401c9eedbe18a05e962 (diff)
downloadunit-14dfa439eed1983693d7d128cc51c5e738a487d7.tar.gz
unit-14dfa439eed1983693d7d128cc51c5e738a487d7.tar.bz2
Router: introduced nxt_http_forward_t.
This makes the replacement of forwarded request header like client_ip and protocol more generic. It's a prerequirement for protocol replacement. No functional changes.
Diffstat (limited to 'src/nxt_http_request.c')
-rw-r--r--src/nxt_http_request.c30
1 files changed, 16 insertions, 14 deletions
diff --git a/src/nxt_http_request.c b/src/nxt_http_request.c
index 0eacf627..3f926796 100644
--- a/src/nxt_http_request.c
+++ b/src/nxt_http_request.c
@@ -314,25 +314,27 @@ nxt_http_request_start(nxt_task_t *task, void *obj, void *data)
static nxt_int_t
nxt_http_request_client_ip(nxt_task_t *task, nxt_http_request_t *r)
{
- u_char *start, *p;
- nxt_int_t ret, i, len;
- nxt_str_t *header;
- nxt_array_t *fields_arr; /* of nxt_http_field_t * */
- nxt_sockaddr_t *sa, *prev_sa;
- nxt_http_field_t *f, **fields;
- nxt_http_client_ip_t *client_ip;
-
- client_ip = r->conf->socket_conf->client_ip;
-
- if (client_ip == NULL) {
+ u_char *start, *p;
+ nxt_int_t ret, i, len;
+ nxt_str_t *header;
+ nxt_array_t *fields_arr; /* of nxt_http_field_t * */
+ nxt_sockaddr_t *sa, *prev_sa;
+ nxt_http_field_t *f, **fields;
+ nxt_http_forward_t *forward;
+ nxt_http_forward_header_t *client_ip;
+
+ forward = r->conf->socket_conf->client_ip;
+
+ if (forward == NULL) {
return NXT_OK;
}
- ret = nxt_http_route_addr_rule(r, client_ip->source, r->remote);
+ ret = nxt_http_route_addr_rule(r, forward->source, r->remote);
if (ret <= 0) {
return NXT_OK;
}
+ client_ip = &forward->client_ip;
header = client_ip->header;
fields_arr = nxt_array_create(r->mem_pool, 2, sizeof(nxt_http_field_t *));
@@ -388,13 +390,13 @@ nxt_http_request_client_ip(nxt_task_t *task, nxt_http_request_t *r)
return NXT_OK;
}
- if (!client_ip->recursive) {
+ if (!forward->recursive) {
r->remote = sa;
return NXT_OK;
}
- ret = nxt_http_route_addr_rule(r, client_ip->source, sa);
+ ret = nxt_http_route_addr_rule(r, forward->source, sa);
if (ret <= 0 || (i == 0 && p == start)) {
r->remote = sa;