nxt_http_route.c (1930:fb8b29aac7a1) nxt_http_route.c (1936:953434450ea9)
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_router.h>
8#include <nxt_http.h>

--- 121 unchanged lines hidden (view full) ---

130typedef struct {
131 /* The object must be the first field. */
132 nxt_http_route_object_t object:8;
133 uint32_t items;
134 nxt_http_route_ruleset_t *ruleset[0];
135} nxt_http_route_table_t;
136
137
1
2/*
3 * Copyright (C) Igor Sysoev
4 * Copyright (C) NGINX, Inc.
5 */
6
7#include <nxt_router.h>
8#include <nxt_http.h>

--- 121 unchanged lines hidden (view full) ---

130typedef struct {
131 /* The object must be the first field. */
132 nxt_http_route_object_t object:8;
133 uint32_t items;
134 nxt_http_route_ruleset_t *ruleset[0];
135} nxt_http_route_table_t;
136
137
138typedef struct {
138struct nxt_http_route_addr_rule_s {
139 /* The object must be the first field. */
140 nxt_http_route_object_t object:8;
141 uint32_t items;
142 nxt_http_route_addr_pattern_t addr_pattern[0];
139 /* The object must be the first field. */
140 nxt_http_route_object_t object:8;
141 uint32_t items;
142 nxt_http_route_addr_pattern_t addr_pattern[0];
143} nxt_http_route_addr_rule_t;
143};
144
145
146typedef union {
147 nxt_http_route_rule_t *rule;
148 nxt_http_route_table_t *table;
149 nxt_http_route_addr_rule_t *addr_rule;
150} nxt_http_route_test_t;
151

--- 37 unchanged lines hidden (view full) ---

189 nxt_mp_t *mp, nxt_conf_value_t *table_cv, nxt_http_route_object_t object,
190 nxt_bool_t case_sensitive, nxt_http_route_encoding_t encoding);
191static nxt_http_route_ruleset_t *nxt_http_route_ruleset_create(nxt_task_t *task,
192 nxt_mp_t *mp, nxt_conf_value_t *ruleset_cv, nxt_http_route_object_t object,
193 nxt_bool_t case_sensitive, nxt_http_route_encoding_t encoding);
194static nxt_http_route_rule_t *nxt_http_route_rule_name_create(nxt_task_t *task,
195 nxt_mp_t *mp, nxt_conf_value_t *rule_cv, nxt_str_t *name,
196 nxt_bool_t case_sensitive, nxt_http_route_encoding_t encoding);
144
145
146typedef union {
147 nxt_http_route_rule_t *rule;
148 nxt_http_route_table_t *table;
149 nxt_http_route_addr_rule_t *addr_rule;
150} nxt_http_route_test_t;
151

--- 37 unchanged lines hidden (view full) ---

189 nxt_mp_t *mp, nxt_conf_value_t *table_cv, nxt_http_route_object_t object,
190 nxt_bool_t case_sensitive, nxt_http_route_encoding_t encoding);
191static nxt_http_route_ruleset_t *nxt_http_route_ruleset_create(nxt_task_t *task,
192 nxt_mp_t *mp, nxt_conf_value_t *ruleset_cv, nxt_http_route_object_t object,
193 nxt_bool_t case_sensitive, nxt_http_route_encoding_t encoding);
194static nxt_http_route_rule_t *nxt_http_route_rule_name_create(nxt_task_t *task,
195 nxt_mp_t *mp, nxt_conf_value_t *rule_cv, nxt_str_t *name,
196 nxt_bool_t case_sensitive, nxt_http_route_encoding_t encoding);
197static nxt_http_route_addr_rule_t *nxt_http_route_addr_rule_create(
198 nxt_task_t *task, nxt_mp_t *mp, nxt_conf_value_t *cv);
199static nxt_http_route_rule_t *nxt_http_route_rule_create(nxt_task_t *task,
200 nxt_mp_t *mp, nxt_conf_value_t *cv, nxt_bool_t case_sensitive,
201 nxt_http_route_pattern_case_t pattern_case,
202 nxt_http_route_encoding_t encoding);
203static int nxt_http_pattern_compare(const void *one, const void *two);
204static int nxt_http_addr_pattern_compare(const void *one, const void *two);
205static nxt_int_t nxt_http_route_pattern_create(nxt_task_t *task, nxt_mp_t *mp,
206 nxt_conf_value_t *cv, nxt_http_route_pattern_t *pattern,

--- 25 unchanged lines hidden (view full) ---

232static nxt_http_action_t *nxt_http_route_handler(nxt_task_t *task,
233 nxt_http_request_t *r, nxt_http_action_t *start);
234static nxt_http_action_t *nxt_http_route_match(nxt_task_t *task,
235 nxt_http_request_t *r, nxt_http_route_match_t *match);
236static nxt_int_t nxt_http_route_table(nxt_http_request_t *r,
237 nxt_http_route_table_t *table);
238static nxt_int_t nxt_http_route_ruleset(nxt_http_request_t *r,
239 nxt_http_route_ruleset_t *ruleset);
197static nxt_http_route_rule_t *nxt_http_route_rule_create(nxt_task_t *task,
198 nxt_mp_t *mp, nxt_conf_value_t *cv, nxt_bool_t case_sensitive,
199 nxt_http_route_pattern_case_t pattern_case,
200 nxt_http_route_encoding_t encoding);
201static int nxt_http_pattern_compare(const void *one, const void *two);
202static int nxt_http_addr_pattern_compare(const void *one, const void *two);
203static nxt_int_t nxt_http_route_pattern_create(nxt_task_t *task, nxt_mp_t *mp,
204 nxt_conf_value_t *cv, nxt_http_route_pattern_t *pattern,

--- 25 unchanged lines hidden (view full) ---

230static nxt_http_action_t *nxt_http_route_handler(nxt_task_t *task,
231 nxt_http_request_t *r, nxt_http_action_t *start);
232static nxt_http_action_t *nxt_http_route_match(nxt_task_t *task,
233 nxt_http_request_t *r, nxt_http_route_match_t *match);
234static nxt_int_t nxt_http_route_table(nxt_http_request_t *r,
235 nxt_http_route_table_t *table);
236static nxt_int_t nxt_http_route_ruleset(nxt_http_request_t *r,
237 nxt_http_route_ruleset_t *ruleset);
240static nxt_int_t nxt_http_route_addr_rule(nxt_http_request_t *r,
241 nxt_http_route_addr_rule_t *addr_rule, nxt_sockaddr_t *sockaddr);
242static nxt_int_t nxt_http_route_rule(nxt_http_request_t *r,
243 nxt_http_route_rule_t *rule);
244static nxt_int_t nxt_http_route_header(nxt_http_request_t *r,
245 nxt_http_route_rule_t *rule);
246static nxt_int_t nxt_http_route_arguments(nxt_http_request_t *r,
247 nxt_http_route_rule_t *rule);
248static nxt_array_t *nxt_http_route_arguments_parse(nxt_http_request_t *r);
249static nxt_http_name_value_t *nxt_http_route_argument(nxt_array_t *array,

--- 685 unchanged lines hidden (view full) ---

935 return NULL;
936 }
937 }
938
939 return rule;
940}
941
942
238static nxt_int_t nxt_http_route_rule(nxt_http_request_t *r,
239 nxt_http_route_rule_t *rule);
240static nxt_int_t nxt_http_route_header(nxt_http_request_t *r,
241 nxt_http_route_rule_t *rule);
242static nxt_int_t nxt_http_route_arguments(nxt_http_request_t *r,
243 nxt_http_route_rule_t *rule);
244static nxt_array_t *nxt_http_route_arguments_parse(nxt_http_request_t *r);
245static nxt_http_name_value_t *nxt_http_route_argument(nxt_array_t *array,

--- 685 unchanged lines hidden (view full) ---

931 return NULL;
932 }
933 }
934
935 return rule;
936}
937
938
943static nxt_http_route_addr_rule_t *
939nxt_http_route_addr_rule_t *
944nxt_http_route_addr_rule_create(nxt_task_t *task, nxt_mp_t *mp,
945 nxt_conf_value_t *cv)
946{
947 size_t size;
948 uint32_t i, n;
949 nxt_bool_t array;
950 nxt_conf_value_t *value;
951 nxt_http_route_addr_rule_t *addr_rule;

--- 970 unchanged lines hidden (view full) ---

1922 match = 0;
1923 break;
1924 }
1925
1926 return match ^ base->negative;
1927}
1928
1929
940nxt_http_route_addr_rule_create(nxt_task_t *task, nxt_mp_t *mp,
941 nxt_conf_value_t *cv)
942{
943 size_t size;
944 uint32_t i, n;
945 nxt_bool_t array;
946 nxt_conf_value_t *value;
947 nxt_http_route_addr_rule_t *addr_rule;

--- 970 unchanged lines hidden (view full) ---

1918 match = 0;
1919 break;
1920 }
1921
1922 return match ^ base->negative;
1923}
1924
1925
1930static nxt_int_t
1926nxt_int_t
1931nxt_http_route_addr_rule(nxt_http_request_t *r,
1932 nxt_http_route_addr_rule_t *addr_rule, nxt_sockaddr_t *sa)
1933{
1934 uint32_t n;
1935 nxt_bool_t matches;
1936 nxt_http_route_addr_pattern_t *p;
1937
1938 n = addr_rule->items;

--- 577 unchanged lines hidden ---
1927nxt_http_route_addr_rule(nxt_http_request_t *r,
1928 nxt_http_route_addr_rule_t *addr_rule, nxt_sockaddr_t *sa)
1929{
1930 uint32_t n;
1931 nxt_bool_t matches;
1932 nxt_http_route_addr_pattern_t *p;
1933
1934 n = addr_rule->items;

--- 577 unchanged lines hidden ---