From 4f16479482f4902aecefdbcd16f3d6e3bf6b67a4 Mon Sep 17 00:00:00 2001 From: Zhidao HONG Date: Thu, 19 May 2022 21:18:25 +0800 Subject: HTTP: generalized uri encoding. No functional changes. --- src/nxt_http.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/nxt_http.h') diff --git a/src/nxt_http.h b/src/nxt_http.h index d299fdd4..37c27325 100644 --- a/src/nxt_http.h +++ b/src/nxt_http.h @@ -207,6 +207,13 @@ typedef struct { } nxt_http_name_value_t; +typedef enum { + NXT_HTTP_URI_ENCODING_NONE = 0, + NXT_HTTP_URI_ENCODING, + NXT_HTTP_URI_ENCODING_PLUS +} nxt_http_uri_encoding_t; + + typedef struct nxt_http_route_s nxt_http_route_t; typedef struct nxt_http_route_rule_s nxt_http_route_rule_t; typedef struct nxt_http_route_addr_rule_s nxt_http_route_addr_rule_t; @@ -324,6 +331,9 @@ nxt_int_t nxt_http_request_content_length(void *ctx, nxt_http_field_t *field, nxt_array_t *nxt_http_arguments_parse(nxt_http_request_t *r); nxt_array_t *nxt_http_cookies_parse(nxt_http_request_t *r); +int64_t nxt_http_field_hash(nxt_mp_t *mp, nxt_str_t *name, + nxt_bool_t case_sensitive, uint8_t encoding); + nxt_http_routes_t *nxt_http_routes_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf, nxt_conf_value_t *routes_conf); nxt_http_action_t *nxt_http_action_create(nxt_task_t *task, -- cgit From 14dfa439eed1983693d7d128cc51c5e738a487d7 Mon Sep 17 00:00:00 2001 From: Zhidao HONG Date: Mon, 20 Jun 2022 13:16:25 +0800 Subject: 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. --- src/nxt_http.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/nxt_http.h') diff --git a/src/nxt_http.h b/src/nxt_http.h index 37c27325..665ccdbf 100644 --- a/src/nxt_http.h +++ b/src/nxt_http.h @@ -273,10 +273,15 @@ typedef struct { } nxt_http_proto_table_t; -struct nxt_http_client_ip_s { - nxt_http_route_addr_rule_t *source; +typedef struct { nxt_str_t *header; uint32_t header_hash; +} nxt_http_forward_header_t; + + +struct nxt_http_forward_s { + nxt_http_forward_header_t client_ip; + nxt_http_route_addr_rule_t *source; uint8_t recursive; /* 1 bit */ }; -- cgit From 9d2672a701e3dcaee45bef9251ab55620d42fa42 Mon Sep 17 00:00:00 2001 From: Zhidao HONG Date: Mon, 20 Jun 2022 13:22:13 +0800 Subject: Router: forwared header replacement. --- src/nxt_http.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/nxt_http.h') diff --git a/src/nxt_http.h b/src/nxt_http.h index 665ccdbf..8fa0caad 100644 --- a/src/nxt_http.h +++ b/src/nxt_http.h @@ -162,7 +162,6 @@ struct nxt_http_request_s { nxt_sockaddr_t *remote; nxt_sockaddr_t *local; - void *tls; nxt_task_t task; nxt_timer_t timer; @@ -190,6 +189,7 @@ struct nxt_http_request_s { uint8_t pass_count; /* 8 bits */ uint8_t app_target; nxt_http_protocol_t protocol:8; /* 2 bits */ + uint8_t tls; /* 1 bit */ uint8_t logged; /* 1 bit */ uint8_t header_sent; /* 1 bit */ uint8_t inconsistent; /* 1 bit */ @@ -281,6 +281,7 @@ typedef struct { struct nxt_http_forward_s { nxt_http_forward_header_t client_ip; + nxt_http_forward_header_t protocol; nxt_http_route_addr_rule_t *source; uint8_t recursive; /* 1 bit */ }; -- cgit From 4418f99cd46b17be893b6bd0df56434078e5aad3 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Thu, 16 Jun 2022 02:00:52 +0100 Subject: Constified numerous function parameters. As was pointed out by the cppcheck[0] static code analysis utility we can mark numerous function parameters as 'const'. This acts as a hint to the compiler about our intentions and the compiler will tell us when we deviate from them. [0]: https://cppcheck.sourceforge.io/ --- src/nxt_http.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/nxt_http.h') diff --git a/src/nxt_http.h b/src/nxt_http.h index 8fa0caad..4064a8a5 100644 --- a/src/nxt_http.h +++ b/src/nxt_http.h @@ -376,8 +376,9 @@ nxt_int_t nxt_http_static_init(nxt_task_t *task, nxt_router_temp_conf_t *tmcf, nxt_http_action_t *action, nxt_http_action_conf_t *acf); nxt_int_t nxt_http_static_mtypes_init(nxt_mp_t *mp, nxt_lvlhsh_t *hash); nxt_int_t nxt_http_static_mtypes_hash_add(nxt_mp_t *mp, nxt_lvlhsh_t *hash, - nxt_str_t *exten, nxt_str_t *type); -nxt_str_t *nxt_http_static_mtype_get(nxt_lvlhsh_t *hash, nxt_str_t *exten); + const nxt_str_t *exten, nxt_str_t *type); +nxt_str_t *nxt_http_static_mtype_get(nxt_lvlhsh_t *hash, + const nxt_str_t *exten); nxt_http_action_t *nxt_http_application_handler(nxt_task_t *task, nxt_http_request_t *r, nxt_http_action_t *action); -- cgit From 45b89e32577eef18e473d0c7ae24562e7efedcc0 Mon Sep 17 00:00:00 2001 From: Zhidao HONG Date: Thu, 14 Jul 2022 04:32:49 +0800 Subject: Var: dynamic variables support. This commit adds the variables $arg_NAME, $header_NAME, and $cookie_NAME. --- src/nxt_http.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/nxt_http.h') diff --git a/src/nxt_http.h b/src/nxt_http.h index 4064a8a5..c2e85840 100644 --- a/src/nxt_http.h +++ b/src/nxt_http.h @@ -339,6 +339,9 @@ nxt_array_t *nxt_http_cookies_parse(nxt_http_request_t *r); int64_t nxt_http_field_hash(nxt_mp_t *mp, nxt_str_t *name, nxt_bool_t case_sensitive, uint8_t encoding); +int64_t nxt_http_argument_hash(nxt_mp_t *mp, nxt_str_t *name); +int64_t nxt_http_header_hash(nxt_mp_t *mp, nxt_str_t *name); +int64_t nxt_http_cookie_hash(nxt_mp_t *mp, nxt_str_t *name); nxt_http_routes_t *nxt_http_routes_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf, nxt_conf_value_t *routes_conf); @@ -369,8 +372,8 @@ nxt_int_t nxt_upstreams_create(nxt_task_t *task, nxt_router_temp_conf_t *tmcf, nxt_int_t nxt_upstreams_joint_create(nxt_router_temp_conf_t *tmcf, nxt_upstream_t ***upstream_joint); -nxt_int_t nxt_http_return_init(nxt_mp_t *mp, nxt_http_action_t *action, - nxt_http_action_conf_t *acf); +nxt_int_t nxt_http_return_init(nxt_router_conf_t *rtcf, + nxt_http_action_t *action, nxt_http_action_conf_t *acf); nxt_int_t nxt_http_static_init(nxt_task_t *task, nxt_router_temp_conf_t *tmcf, nxt_http_action_t *action, nxt_http_action_conf_t *acf); -- cgit