Mercurial > hg > nginx-quic
annotate src/http/ngx_http_variables.h @ 4313:e7db97bfac25
Added support for IP-literal in the Host header and request line (ticket #1).
Additional parsing logic added to correctly handle RFC 3986 compliant IPv6 and
IPvFuture characters enclosed in square brackets.
The host validation was completely rewritten. The behavior for non IP literals
was changed in a more proper and safer way:
- Host part is now delimited either by the first colon or by the end of string
if there's no colon. Previously the last colon was used as delimiter which
allowed substitution of a port number in the $host variable.
(e.g. Host: 127.0.0.1:9000:80)
- Fixed stripping of the ending dot in the Host header when the host was also
followed by a port number.
(e.g. Host: nginx.com.:80)
- Fixed upper case characters detection. Previously it was broken which led to
wasting memory and CPU.
author | Valentin Bartenev <vbart@nginx.com> |
---|---|
date | Mon, 28 Nov 2011 09:15:33 +0000 |
parents | fa4612bfb9fa |
children | d620f497c50f |
rev | line source |
---|---|
499 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4 */ | |
5 | |
6 | |
7 #ifndef _NGX_HTTP_VARIABLES_H_INCLUDED_ | |
8 #define _NGX_HTTP_VARIABLES_H_INCLUDED_ | |
9 | |
10 | |
11 #include <ngx_config.h> | |
12 #include <ngx_core.h> | |
13 #include <ngx_http.h> | |
14 | |
15 | |
1310
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1162
diff
changeset
|
16 typedef ngx_variable_value_t ngx_http_variable_value_t; |
499 | 17 |
2008
66dc85397a90
escape 0x00-0x1f, ", and \ in access log variables
Igor Sysoev <igor@sysoev.ru>
parents:
1565
diff
changeset
|
18 #define ngx_http_variable(v) { sizeof(v) - 1, 1, 0, 0, 0, (u_char *) v } |
573 | 19 |
499 | 20 typedef struct ngx_http_variable_s ngx_http_variable_t; |
21 | |
637 | 22 typedef void (*ngx_http_set_variable_pt) (ngx_http_request_t *r, |
23 ngx_http_variable_value_t *v, uintptr_t data); | |
573 | 24 typedef ngx_int_t (*ngx_http_get_variable_pt) (ngx_http_request_t *r, |
25 ngx_http_variable_value_t *v, uintptr_t data); | |
499 | 26 |
27 | |
1565 | 28 #define NGX_HTTP_VAR_CHANGEABLE 1 |
29 #define NGX_HTTP_VAR_NOCACHEABLE 2 | |
30 #define NGX_HTTP_VAR_INDEXED 4 | |
31 #define NGX_HTTP_VAR_NOHASH 8 | |
509 | 32 |
33 | |
499 | 34 struct ngx_http_variable_s { |
573 | 35 ngx_str_t name; /* must be first to build the hash */ |
637 | 36 ngx_http_set_variable_pt set_handler; |
37 ngx_http_get_variable_pt get_handler; | |
573 | 38 uintptr_t data; |
39 ngx_uint_t flags; | |
40 ngx_uint_t index; | |
499 | 41 }; |
42 | |
43 | |
501 | 44 ngx_http_variable_t *ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name, |
509 | 45 ngx_uint_t flags); |
46 ngx_int_t ngx_http_get_variable_index(ngx_conf_t *cf, ngx_str_t *name); | |
499 | 47 ngx_http_variable_value_t *ngx_http_get_indexed_variable(ngx_http_request_t *r, |
48 ngx_uint_t index); | |
573 | 49 ngx_http_variable_value_t *ngx_http_get_flushed_variable(ngx_http_request_t *r, |
50 ngx_uint_t index); | |
51 | |
499 | 52 ngx_http_variable_value_t *ngx_http_get_variable(ngx_http_request_t *r, |
3500
0eb46e3c5c02
change processing variables accessed by SSI and perl module:
Igor Sysoev <igor@sysoev.ru>
parents:
3356
diff
changeset
|
53 ngx_str_t *name, ngx_uint_t key); |
509 | 54 |
1162 | 55 ngx_int_t ngx_http_variable_unknown_header(ngx_http_variable_value_t *v, |
56 ngx_str_t *var, ngx_list_part_t *part, size_t prefix); | |
57 | |
58 | |
573 | 59 #define ngx_http_clear_variable(r, index) r->variables0[index].text.data = NULL; |
60 | |
61 | |
3356
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
62 #if (NGX_PCRE) |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
63 |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
64 typedef struct { |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
65 ngx_uint_t capture; |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
66 ngx_int_t index; |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
67 } ngx_http_regex_variable_t; |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
68 |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
69 |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
70 typedef struct { |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
71 ngx_regex_t *regex; |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
72 ngx_uint_t ncaptures; |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
73 ngx_http_regex_variable_t *variables; |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
74 ngx_uint_t nvariables; |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
75 ngx_str_t name; |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
76 } ngx_http_regex_t; |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
77 |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
78 |
3872
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
79 typedef struct { |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
80 ngx_http_regex_t *regex; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
81 void *value; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
82 } ngx_http_map_regex_t; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
83 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
84 |
3325 | 85 ngx_http_regex_t *ngx_http_regex_compile(ngx_conf_t *cf, |
86 ngx_regex_compile_t *rc); | |
87 ngx_int_t ngx_http_regex_exec(ngx_http_request_t *r, ngx_http_regex_t *re, | |
88 ngx_str_t *s); | |
89 | |
3356
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
90 #endif |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
91 |
3325 | 92 |
3872
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
93 typedef struct { |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
94 ngx_hash_combined_t hash; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
95 #if (NGX_PCRE) |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
96 ngx_http_map_regex_t *regex; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
97 ngx_uint_t nregex; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
98 #endif |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
99 } ngx_http_map_t; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
100 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
101 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
102 void *ngx_http_map_find(ngx_http_request_t *r, ngx_http_map_t *map, |
3929
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
103 ngx_str_t *match); |
3872
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
104 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
105 |
509 | 106 ngx_int_t ngx_http_variables_add_core_vars(ngx_conf_t *cf); |
107 ngx_int_t ngx_http_variables_init_vars(ngx_conf_t *cf); | |
499 | 108 |
109 | |
577 | 110 extern ngx_http_variable_value_t ngx_http_variable_null_value; |
111 extern ngx_http_variable_value_t ngx_http_variable_true_value; | |
112 | |
113 | |
499 | 114 #endif /* _NGX_HTTP_VARIABLES_H_INCLUDED_ */ |