Mercurial > hg > nginx
annotate src/http/ngx_http_variables.c @ 4964:2464ccebdb52
Upstream: fixed SIGSEGV with the "if" directive.
Configuration like
location / {
set $true 1;
if ($true) {
proxy_pass http://backend;
}
if ($true) {
# nothing
}
}
resulted in segmentation fault due to NULL pointer dereference as the
upstream configuration wasn't initialized in an implicit location created
by the last if(), but the r->content_handler was set due to first if().
Instead of committing a suicide by dereferencing a NULL pointer, return
500 (Internal Server Error) in such cases, i.e. if uscf is NULL. Better
fix would be to avoid such cases by fixing the "if" directive handling,
but it's out of scope of this patch.
Prodded by Piotr Sikora.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 13 Dec 2012 16:05:59 +0000 |
parents | ec7d97006a30 |
children | 8b635cf36ccc |
rev | line source |
---|---|
499 | 1 |
2 /* | |
3 * Copyright (C) Igor Sysoev | |
4412 | 4 * Copyright (C) Nginx, Inc. |
499 | 5 */ |
6 | |
7 | |
8 #include <ngx_config.h> | |
9 #include <ngx_core.h> | |
10 #include <ngx_http.h> | |
1329 | 11 #include <nginx.h> |
499 | 12 |
13 | |
573 | 14 static ngx_int_t ngx_http_variable_request(ngx_http_request_t *r, |
15 ngx_http_variable_value_t *v, uintptr_t data); | |
1350 | 16 static void ngx_http_variable_request_set(ngx_http_request_t *r, |
17 ngx_http_variable_value_t *v, uintptr_t data); | |
3282
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
18 static ngx_int_t ngx_http_variable_request_get_size(ngx_http_request_t *r, |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
19 ngx_http_variable_value_t *v, uintptr_t data); |
637 | 20 static void ngx_http_variable_request_set_size(ngx_http_request_t *r, |
21 ngx_http_variable_value_t *v, uintptr_t data); | |
573 | 22 static ngx_int_t ngx_http_variable_header(ngx_http_request_t *r, |
23 ngx_http_variable_value_t *v, uintptr_t data); | |
24 static ngx_int_t ngx_http_variable_headers(ngx_http_request_t *r, | |
25 ngx_http_variable_value_t *v, uintptr_t data); | |
577 | 26 |
27 static ngx_int_t ngx_http_variable_unknown_header_in(ngx_http_request_t *r, | |
573 | 28 ngx_http_variable_value_t *v, uintptr_t data); |
577 | 29 static ngx_int_t ngx_http_variable_unknown_header_out(ngx_http_request_t *r, |
30 ngx_http_variable_value_t *v, uintptr_t data); | |
3144
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
31 static ngx_int_t ngx_http_variable_request_line(ngx_http_request_t *r, |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
32 ngx_http_variable_value_t *v, uintptr_t data); |
2359
4fee4ebbfb0b
$cookie_... variable did not for SSI and perl
Igor Sysoev <igor@sysoev.ru>
parents:
2333
diff
changeset
|
33 static ngx_int_t ngx_http_variable_cookie(ngx_http_request_t *r, |
4fee4ebbfb0b
$cookie_... variable did not for SSI and perl
Igor Sysoev <igor@sysoev.ru>
parents:
2333
diff
changeset
|
34 ngx_http_variable_value_t *v, uintptr_t data); |
2137 | 35 static ngx_int_t ngx_http_variable_argument(ngx_http_request_t *r, |
36 ngx_http_variable_value_t *v, uintptr_t data); | |
4545
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
37 #if (NGX_HAVE_TCP_INFO) |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
38 static ngx_int_t ngx_http_variable_tcpinfo(ngx_http_request_t *r, |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
39 ngx_http_variable_value_t *v, uintptr_t data); |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
40 #endif |
577 | 41 |
4928
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
42 static ngx_int_t ngx_http_variable_content_length(ngx_http_request_t *r, |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
43 ngx_http_variable_value_t *v, uintptr_t data); |
573 | 44 static ngx_int_t ngx_http_variable_host(ngx_http_request_t *r, |
45 ngx_http_variable_value_t *v, uintptr_t data); | |
983
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
46 static ngx_int_t ngx_http_variable_binary_remote_addr(ngx_http_request_t *r, |
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
47 ngx_http_variable_value_t *v, uintptr_t data); |
573 | 48 static ngx_int_t ngx_http_variable_remote_addr(ngx_http_request_t *r, |
49 ngx_http_variable_value_t *v, uintptr_t data); | |
50 static ngx_int_t ngx_http_variable_remote_port(ngx_http_request_t *r, | |
51 ngx_http_variable_value_t *v, uintptr_t data); | |
52 static ngx_int_t ngx_http_variable_server_addr(ngx_http_request_t *r, | |
53 ngx_http_variable_value_t *v, uintptr_t data); | |
54 static ngx_int_t ngx_http_variable_server_port(ngx_http_request_t *r, | |
55 ngx_http_variable_value_t *v, uintptr_t data); | |
731 | 56 static ngx_int_t ngx_http_variable_scheme(ngx_http_request_t *r, |
57 ngx_http_variable_value_t *v, uintptr_t data); | |
4332
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
58 static ngx_int_t ngx_http_variable_https(ngx_http_request_t *r, |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
59 ngx_http_variable_value_t *v, uintptr_t data); |
1351 | 60 static ngx_int_t ngx_http_variable_is_args(ngx_http_request_t *r, |
61 ngx_http_variable_value_t *v, uintptr_t data); | |
573 | 62 static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r, |
63 ngx_http_variable_value_t *v, uintptr_t data); | |
2259 | 64 static ngx_int_t ngx_http_variable_realpath_root(ngx_http_request_t *r, |
65 ngx_http_variable_value_t *v, uintptr_t data); | |
573 | 66 static ngx_int_t ngx_http_variable_request_filename(ngx_http_request_t *r, |
67 ngx_http_variable_value_t *v, uintptr_t data); | |
1811 | 68 static ngx_int_t ngx_http_variable_server_name(ngx_http_request_t *r, |
69 ngx_http_variable_value_t *v, uintptr_t data); | |
573 | 70 static ngx_int_t ngx_http_variable_request_method(ngx_http_request_t *r, |
71 ngx_http_variable_value_t *v, uintptr_t data); | |
72 static ngx_int_t ngx_http_variable_remote_user(ngx_http_request_t *r, | |
73 ngx_http_variable_value_t *v, uintptr_t data); | |
4886 | 74 static ngx_int_t ngx_http_variable_bytes_sent(ngx_http_request_t *r, |
75 ngx_http_variable_value_t *v, uintptr_t data); | |
611 | 76 static ngx_int_t ngx_http_variable_body_bytes_sent(ngx_http_request_t *r, |
77 ngx_http_variable_value_t *v, uintptr_t data); | |
629 | 78 static ngx_int_t ngx_http_variable_request_completion(ngx_http_request_t *r, |
79 ngx_http_variable_value_t *v, uintptr_t data); | |
2844 | 80 static ngx_int_t ngx_http_variable_request_body(ngx_http_request_t *r, |
81 ngx_http_variable_value_t *v, uintptr_t data); | |
759 | 82 static ngx_int_t ngx_http_variable_request_body_file(ngx_http_request_t *r, |
83 ngx_http_variable_value_t *v, uintptr_t data); | |
4913
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
84 static ngx_int_t ngx_http_variable_request_time(ngx_http_request_t *r, |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
85 ngx_http_variable_value_t *v, uintptr_t data); |
4685
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
86 static ngx_int_t ngx_http_variable_status(ngx_http_request_t *r, |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
87 ngx_http_variable_value_t *v, uintptr_t data); |
4686 | 88 |
641 | 89 static ngx_int_t ngx_http_variable_sent_content_type(ngx_http_request_t *r, |
90 ngx_http_variable_value_t *v, uintptr_t data); | |
91 static ngx_int_t ngx_http_variable_sent_content_length(ngx_http_request_t *r, | |
92 ngx_http_variable_value_t *v, uintptr_t data); | |
2485
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
93 static ngx_int_t ngx_http_variable_sent_location(ngx_http_request_t *r, |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
94 ngx_http_variable_value_t *v, uintptr_t data); |
641 | 95 static ngx_int_t ngx_http_variable_sent_last_modified(ngx_http_request_t *r, |
96 ngx_http_variable_value_t *v, uintptr_t data); | |
97 static ngx_int_t ngx_http_variable_sent_connection(ngx_http_request_t *r, | |
98 ngx_http_variable_value_t *v, uintptr_t data); | |
99 static ngx_int_t ngx_http_variable_sent_keep_alive(ngx_http_request_t *r, | |
100 ngx_http_variable_value_t *v, uintptr_t data); | |
101 static ngx_int_t ngx_http_variable_sent_transfer_encoding(ngx_http_request_t *r, | |
102 ngx_http_variable_value_t *v, uintptr_t data); | |
103 | |
4893
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
104 static ngx_int_t ngx_http_variable_connection(ngx_http_request_t *r, |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
105 ngx_http_variable_value_t *v, uintptr_t data); |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
106 static ngx_int_t ngx_http_variable_connection_requests(ngx_http_request_t *r, |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
107 ngx_http_variable_value_t *v, uintptr_t data); |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
108 |
1329 | 109 static ngx_int_t ngx_http_variable_nginx_version(ngx_http_request_t *r, |
110 ngx_http_variable_value_t *v, uintptr_t data); | |
2011 | 111 static ngx_int_t ngx_http_variable_hostname(ngx_http_request_t *r, |
112 ngx_http_variable_value_t *v, uintptr_t data); | |
2249 | 113 static ngx_int_t ngx_http_variable_pid(ngx_http_request_t *r, |
114 ngx_http_variable_value_t *v, uintptr_t data); | |
4913
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
115 static ngx_int_t ngx_http_variable_msec(ngx_http_request_t *r, |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
116 ngx_http_variable_value_t *v, uintptr_t data); |
499 | 117 |
509 | 118 /* |
119 * TODO: | |
120 * Apache CGI: AUTH_TYPE, PATH_INFO (null), PATH_TRANSLATED | |
121 * REMOTE_HOST (null), REMOTE_IDENT (null), | |
122 * SERVER_SOFTWARE | |
123 * | |
571 | 124 * Apache SSI: DOCUMENT_NAME, LAST_MODIFIED, USER_NAME (file owner) |
509 | 125 */ |
499 | 126 |
641 | 127 /* |
128 * the $http_host, $http_user_agent, $http_referer, $http_via, | |
129 * and $http_x_forwarded_for variables may be handled by generic | |
4572
67653855682e
Fixed spelling in multiline C comments.
Ruslan Ermilov <ru@nginx.com>
parents:
4558
diff
changeset
|
130 * ngx_http_variable_unknown_header_in(), but for performance reasons |
641 | 131 * they are handled using dedicated entries |
132 */ | |
133 | |
509 | 134 static ngx_http_variable_t ngx_http_core_variables[] = { |
135 | |
637 | 136 { ngx_string("http_host"), NULL, ngx_http_variable_header, |
533 | 137 offsetof(ngx_http_request_t, headers_in.host), 0, 0 }, |
499 | 138 |
637 | 139 { ngx_string("http_user_agent"), NULL, ngx_http_variable_header, |
533 | 140 offsetof(ngx_http_request_t, headers_in.user_agent), 0, 0 }, |
509 | 141 |
637 | 142 { ngx_string("http_referer"), NULL, ngx_http_variable_header, |
533 | 143 offsetof(ngx_http_request_t, headers_in.referer), 0, 0 }, |
499 | 144 |
145 #if (NGX_HTTP_GZIP) | |
637 | 146 { ngx_string("http_via"), NULL, ngx_http_variable_header, |
533 | 147 offsetof(ngx_http_request_t, headers_in.via), 0, 0 }, |
499 | 148 #endif |
149 | |
4697
09187f9b0950
Fixed compile-time conditionals used to detect if X-Forwarded-For support
Ruslan Ermilov <ru@nginx.com>
parents:
4686
diff
changeset
|
150 #if (NGX_HTTP_X_FORWARDED_FOR) |
637 | 151 { ngx_string("http_x_forwarded_for"), NULL, ngx_http_variable_header, |
533 | 152 offsetof(ngx_http_request_t, headers_in.x_forwarded_for), 0, 0 }, |
499 | 153 #endif |
154 | |
637 | 155 { ngx_string("http_cookie"), NULL, ngx_http_variable_headers, |
533 | 156 offsetof(ngx_http_request_t, headers_in.cookies), 0, 0 }, |
515 | 157 |
4928
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
158 { ngx_string("content_length"), NULL, ngx_http_variable_content_length, |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
159 0, 0, 0 }, |
509 | 160 |
637 | 161 { ngx_string("content_type"), NULL, ngx_http_variable_header, |
533 | 162 offsetof(ngx_http_request_t, headers_in.content_type), 0, 0 }, |
509 | 163 |
637 | 164 { ngx_string("host"), NULL, ngx_http_variable_host, 0, 0, 0 }, |
509 | 165 |
982 | 166 { ngx_string("binary_remote_addr"), NULL, |
983
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
167 ngx_http_variable_binary_remote_addr, 0, 0, 0 }, |
982 | 168 |
637 | 169 { ngx_string("remote_addr"), NULL, ngx_http_variable_remote_addr, 0, 0, 0 }, |
499 | 170 |
637 | 171 { ngx_string("remote_port"), NULL, ngx_http_variable_remote_port, 0, 0, 0 }, |
509 | 172 |
637 | 173 { ngx_string("server_addr"), NULL, ngx_http_variable_server_addr, 0, 0, 0 }, |
509 | 174 |
637 | 175 { ngx_string("server_port"), NULL, ngx_http_variable_server_port, 0, 0, 0 }, |
509 | 176 |
637 | 177 { ngx_string("server_protocol"), NULL, ngx_http_variable_request, |
533 | 178 offsetof(ngx_http_request_t, http_protocol), 0, 0 }, |
509 | 179 |
731 | 180 { ngx_string("scheme"), NULL, ngx_http_variable_scheme, 0, 0, 0 }, |
181 | |
4332
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
182 { ngx_string("https"), NULL, ngx_http_variable_https, 0, 0, 0 }, |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
183 |
637 | 184 { ngx_string("request_uri"), NULL, ngx_http_variable_request, |
533 | 185 offsetof(ngx_http_request_t, unparsed_uri), 0, 0 }, |
499 | 186 |
637 | 187 { ngx_string("uri"), NULL, ngx_http_variable_request, |
188 offsetof(ngx_http_request_t, uri), | |
1565 | 189 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
637 | 190 |
191 { ngx_string("document_uri"), NULL, ngx_http_variable_request, | |
573 | 192 offsetof(ngx_http_request_t, uri), |
1565 | 193 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
573 | 194 |
3144
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
195 { ngx_string("request"), NULL, ngx_http_variable_request_line, 0, 0, 0 }, |
569 | 196 |
637 | 197 { ngx_string("document_root"), NULL, |
1565 | 198 ngx_http_variable_document_root, 0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
509 | 199 |
2259 | 200 { ngx_string("realpath_root"), NULL, |
201 ngx_http_variable_realpath_root, 0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, | |
202 | |
637 | 203 { ngx_string("query_string"), NULL, ngx_http_variable_request, |
509 | 204 offsetof(ngx_http_request_t, args), |
1565 | 205 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
499 | 206 |
1350 | 207 { ngx_string("args"), |
208 ngx_http_variable_request_set, | |
209 ngx_http_variable_request, | |
589 | 210 offsetof(ngx_http_request_t, args), |
1565 | 211 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
589 | 212 |
1351 | 213 { ngx_string("is_args"), NULL, ngx_http_variable_is_args, |
1565 | 214 0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
1351 | 215 |
637 | 216 { ngx_string("request_filename"), NULL, |
217 ngx_http_variable_request_filename, 0, | |
1565 | 218 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
509 | 219 |
1811 | 220 { ngx_string("server_name"), NULL, ngx_http_variable_server_name, 0, 0, 0 }, |
509 | 221 |
637 | 222 { ngx_string("request_method"), NULL, |
3463
0904bd7d5b37
make $request_method non-cacheable
Igor Sysoev <igor@sysoev.ru>
parents:
3451
diff
changeset
|
223 ngx_http_variable_request_method, 0, |
0904bd7d5b37
make $request_method non-cacheable
Igor Sysoev <igor@sysoev.ru>
parents:
3451
diff
changeset
|
224 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
509 | 225 |
637 | 226 { ngx_string("remote_user"), NULL, ngx_http_variable_remote_user, 0, 0, 0 }, |
509 | 227 |
4886 | 228 { ngx_string("bytes_sent"), NULL, ngx_http_variable_bytes_sent, |
229 0, 0, 0 }, | |
230 | |
637 | 231 { ngx_string("body_bytes_sent"), NULL, ngx_http_variable_body_bytes_sent, |
611 | 232 0, 0, 0 }, |
233 | |
637 | 234 { ngx_string("request_completion"), NULL, |
235 ngx_http_variable_request_completion, | |
629 | 236 0, 0, 0 }, |
237 | |
2844 | 238 { ngx_string("request_body"), NULL, |
239 ngx_http_variable_request_body, | |
240 0, 0, 0 }, | |
241 | |
759 | 242 { ngx_string("request_body_file"), NULL, |
243 ngx_http_variable_request_body_file, | |
244 0, 0, 0 }, | |
245 | |
4913
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
246 { ngx_string("request_time"), NULL, ngx_http_variable_request_time, |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
247 0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
248 |
4685
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
249 { ngx_string("status"), NULL, |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
250 ngx_http_variable_status, 0, |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
251 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
252 |
641 | 253 { ngx_string("sent_http_content_type"), NULL, |
254 ngx_http_variable_sent_content_type, 0, 0, 0 }, | |
255 | |
256 { ngx_string("sent_http_content_length"), NULL, | |
257 ngx_http_variable_sent_content_length, 0, 0, 0 }, | |
258 | |
2485
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
259 { ngx_string("sent_http_location"), NULL, |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
260 ngx_http_variable_sent_location, 0, 0, 0 }, |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
261 |
641 | 262 { ngx_string("sent_http_last_modified"), NULL, |
263 ngx_http_variable_sent_last_modified, 0, 0, 0 }, | |
264 | |
265 { ngx_string("sent_http_connection"), NULL, | |
266 ngx_http_variable_sent_connection, 0, 0, 0 }, | |
267 | |
268 { ngx_string("sent_http_keep_alive"), NULL, | |
269 ngx_http_variable_sent_keep_alive, 0, 0, 0 }, | |
270 | |
271 { ngx_string("sent_http_transfer_encoding"), NULL, | |
272 ngx_http_variable_sent_transfer_encoding, 0, 0, 0 }, | |
273 | |
274 { ngx_string("sent_http_cache_control"), NULL, ngx_http_variable_headers, | |
275 offsetof(ngx_http_request_t, headers_out.cache_control), 0, 0 }, | |
276 | |
637 | 277 { ngx_string("limit_rate"), ngx_http_variable_request_set_size, |
3282
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
278 ngx_http_variable_request_get_size, |
637 | 279 offsetof(ngx_http_request_t, limit_rate), |
1565 | 280 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
637 | 281 |
4893
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
282 { ngx_string("connection"), NULL, |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
283 ngx_http_variable_connection, 0, 0, 0 }, |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
284 |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
285 { ngx_string("connection_requests"), NULL, |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
286 ngx_http_variable_connection_requests, 0, 0, 0 }, |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
287 |
1329 | 288 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version, |
289 0, 0, 0 }, | |
290 | |
2011 | 291 { ngx_string("hostname"), NULL, ngx_http_variable_hostname, |
292 0, 0, 0 }, | |
293 | |
2249 | 294 { ngx_string("pid"), NULL, ngx_http_variable_pid, |
295 0, 0, 0 }, | |
296 | |
4913
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
297 { ngx_string("msec"), NULL, ngx_http_variable_msec, |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
298 0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
299 |
4545
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
300 #if (NGX_HAVE_TCP_INFO) |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
301 { ngx_string("tcpinfo_rtt"), NULL, ngx_http_variable_tcpinfo, |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
302 0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
303 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
304 { ngx_string("tcpinfo_rttvar"), NULL, ngx_http_variable_tcpinfo, |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
305 1, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
306 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
307 { ngx_string("tcpinfo_snd_cwnd"), NULL, ngx_http_variable_tcpinfo, |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
308 2, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
309 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
310 { ngx_string("tcpinfo_rcv_space"), NULL, ngx_http_variable_tcpinfo, |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
311 3, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
312 #endif |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
313 |
637 | 314 { ngx_null_string, NULL, NULL, 0, 0, 0 } |
499 | 315 }; |
316 | |
317 | |
577 | 318 ngx_http_variable_value_t ngx_http_variable_null_value = |
319 ngx_http_variable(""); | |
320 ngx_http_variable_value_t ngx_http_variable_true_value = | |
321 ngx_http_variable("1"); | |
322 | |
323 | |
499 | 324 ngx_http_variable_t * |
509 | 325 ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name, ngx_uint_t flags) |
326 { | |
611 | 327 ngx_int_t rc; |
509 | 328 ngx_uint_t i; |
611 | 329 ngx_hash_key_t *key; |
509 | 330 ngx_http_variable_t *v; |
331 ngx_http_core_main_conf_t *cmcf; | |
332 | |
333 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); | |
334 | |
611 | 335 key = cmcf->variables_keys->keys.elts; |
336 for (i = 0; i < cmcf->variables_keys->keys.nelts; i++) { | |
337 if (name->len != key[i].key.len | |
338 || ngx_strncasecmp(name->data, key[i].key.data, name->len) != 0) | |
509 | 339 { |
340 continue; | |
341 } | |
342 | |
611 | 343 v = key[i].value; |
344 | |
1565 | 345 if (!(v->flags & NGX_HTTP_VAR_CHANGEABLE)) { |
509 | 346 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
347 "the duplicate \"%V\" variable", name); | |
348 return NULL; | |
349 } | |
350 | |
611 | 351 return v; |
509 | 352 } |
353 | |
611 | 354 v = ngx_palloc(cf->pool, sizeof(ngx_http_variable_t)); |
509 | 355 if (v == NULL) { |
356 return NULL; | |
357 } | |
358 | |
359 v->name.len = name->len; | |
2049 | 360 v->name.data = ngx_pnalloc(cf->pool, name->len); |
509 | 361 if (v->name.data == NULL) { |
362 return NULL; | |
363 } | |
364 | |
2135 | 365 ngx_strlow(v->name.data, name->data, name->len); |
509 | 366 |
637 | 367 v->set_handler = NULL; |
368 v->get_handler = NULL; | |
509 | 369 v->data = 0; |
370 v->flags = flags; | |
533 | 371 v->index = 0; |
509 | 372 |
611 | 373 rc = ngx_hash_add_key(cmcf->variables_keys, &v->name, v, 0); |
374 | |
375 if (rc == NGX_ERROR) { | |
376 return NULL; | |
377 } | |
378 | |
379 if (rc == NGX_BUSY) { | |
380 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
381 "conflicting variable name \"%V\"", name); | |
382 return NULL; | |
383 } | |
384 | |
509 | 385 return v; |
386 } | |
387 | |
388 | |
389 ngx_int_t | |
390 ngx_http_get_variable_index(ngx_conf_t *cf, ngx_str_t *name) | |
499 | 391 { |
501 | 392 ngx_uint_t i; |
393 ngx_http_variable_t *v; | |
499 | 394 ngx_http_core_main_conf_t *cmcf; |
395 | |
396 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); | |
397 | |
501 | 398 v = cmcf->variables.elts; |
399 | |
400 if (v == NULL) { | |
499 | 401 if (ngx_array_init(&cmcf->variables, cf->pool, 4, |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2533
diff
changeset
|
402 sizeof(ngx_http_variable_t)) |
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2533
diff
changeset
|
403 != NGX_OK) |
499 | 404 { |
509 | 405 return NGX_ERROR; |
499 | 406 } |
501 | 407 |
408 } else { | |
409 for (i = 0; i < cmcf->variables.nelts; i++) { | |
410 if (name->len != v[i].name.len | |
411 || ngx_strncasecmp(name->data, v[i].name.data, name->len) != 0) | |
412 { | |
413 continue; | |
414 } | |
415 | |
509 | 416 return i; |
501 | 417 } |
499 | 418 } |
419 | |
501 | 420 v = ngx_array_push(&cmcf->variables); |
421 if (v == NULL) { | |
509 | 422 return NGX_ERROR; |
499 | 423 } |
424 | |
501 | 425 v->name.len = name->len; |
2049 | 426 v->name.data = ngx_pnalloc(cf->pool, name->len); |
501 | 427 if (v->name.data == NULL) { |
509 | 428 return NGX_ERROR; |
501 | 429 } |
499 | 430 |
2135 | 431 ngx_strlow(v->name.data, name->data, name->len); |
501 | 432 |
637 | 433 v->set_handler = NULL; |
434 v->get_handler = NULL; | |
501 | 435 v->data = 0; |
509 | 436 v->flags = 0; |
533 | 437 v->index = cmcf->variables.nelts - 1; |
501 | 438 |
4540
cab9aa79256c
Slight optimization in ngx_http_get_variable_index().
Ruslan Ermilov <ru@nginx.com>
parents:
4470
diff
changeset
|
439 return v->index; |
499 | 440 } |
441 | |
442 | |
443 ngx_http_variable_value_t * | |
444 ngx_http_get_indexed_variable(ngx_http_request_t *r, ngx_uint_t index) | |
445 { | |
501 | 446 ngx_http_variable_t *v; |
499 | 447 ngx_http_core_main_conf_t *cmcf; |
448 | |
449 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | |
450 | |
553 | 451 if (cmcf->variables.nelts <= index) { |
499 | 452 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, |
453 "unknown variable index: %d", index); | |
454 return NULL; | |
455 } | |
456 | |
573 | 457 if (r->variables[index].not_found || r->variables[index].valid) { |
458 return &r->variables[index]; | |
501 | 459 } |
499 | 460 |
501 | 461 v = cmcf->variables.elts; |
499 | 462 |
637 | 463 if (v[index].get_handler(r, &r->variables[index], v[index].data) |
464 == NGX_OK) | |
465 { | |
1565 | 466 if (v[index].flags & NGX_HTTP_VAR_NOCACHEABLE) { |
467 r->variables[index].no_cacheable = 1; | |
499 | 468 } |
573 | 469 |
470 return &r->variables[index]; | |
499 | 471 } |
472 | |
657 | 473 r->variables[index].valid = 0; |
474 r->variables[index].not_found = 1; | |
475 | |
798 | 476 return NULL; |
573 | 477 } |
478 | |
479 | |
480 ngx_http_variable_value_t * | |
481 ngx_http_get_flushed_variable(ngx_http_request_t *r, ngx_uint_t index) | |
482 { | |
1150 | 483 ngx_http_variable_value_t *v; |
573 | 484 |
485 v = &r->variables[index]; | |
486 | |
4470
d9bf6caf0371
Variables: honor no_cacheable for not_found variables.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4412
diff
changeset
|
487 if (v->valid || v->not_found) { |
1565 | 488 if (!v->no_cacheable) { |
573 | 489 return v; |
490 } | |
491 | |
492 v->valid = 0; | |
493 v->not_found = 0; | |
509 | 494 } |
501 | 495 |
573 | 496 return ngx_http_get_indexed_variable(r, index); |
499 | 497 } |
498 | |
499 | |
500 ngx_http_variable_value_t * | |
3500
0eb46e3c5c02
change processing variables accessed by SSI and perl module:
Igor Sysoev <igor@sysoev.ru>
parents:
3499
diff
changeset
|
501 ngx_http_get_variable(ngx_http_request_t *r, ngx_str_t *name, ngx_uint_t key) |
499 | 502 { |
501 | 503 ngx_http_variable_t *v; |
573 | 504 ngx_http_variable_value_t *vv; |
499 | 505 ngx_http_core_main_conf_t *cmcf; |
506 | |
507 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | |
508 | |
611 | 509 v = ngx_hash_find(&cmcf->variables_hash, key, name->data, name->len); |
499 | 510 |
611 | 511 if (v) { |
512 if (v->flags & NGX_HTTP_VAR_INDEXED) { | |
3500
0eb46e3c5c02
change processing variables accessed by SSI and perl module:
Igor Sysoev <igor@sysoev.ru>
parents:
3499
diff
changeset
|
513 return ngx_http_get_flushed_variable(r, v->index); |
519 | 514 |
515 } else { | |
499 | 516 |
573 | 517 vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)); |
501 | 518 |
637 | 519 if (vv && v->get_handler(r, vv, v->data) == NGX_OK) { |
573 | 520 return vv; |
521 } | |
509 | 522 |
573 | 523 return NULL; |
524 } | |
509 | 525 } |
526 | |
527 vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t)); | |
528 if (vv == NULL) { | |
529 return NULL; | |
530 } | |
531 | |
573 | 532 if (ngx_strncmp(name->data, "http_", 5) == 0) { |
499 | 533 |
577 | 534 if (ngx_http_variable_unknown_header_in(r, vv, (uintptr_t) name) |
535 == NGX_OK) | |
536 { | |
537 return vv; | |
538 } | |
539 | |
540 return NULL; | |
541 } | |
542 | |
543 if (ngx_strncmp(name->data, "sent_http_", 10) == 0) { | |
544 | |
545 if (ngx_http_variable_unknown_header_out(r, vv, (uintptr_t) name) | |
546 == NGX_OK) | |
573 | 547 { |
548 return vv; | |
549 } | |
499 | 550 |
551 return NULL; | |
552 } | |
553 | |
3451
7a1958778351
fix $upstream_http_ variable prefix length
Igor Sysoev <igor@sysoev.ru>
parents:
3409
diff
changeset
|
554 if (ngx_strncmp(name->data, "upstream_http_", 14) == 0) { |
1162 | 555 |
556 if (ngx_http_upstream_header_variable(r, vv, (uintptr_t) name) | |
557 == NGX_OK) | |
558 { | |
559 return vv; | |
560 } | |
561 | |
562 return NULL; | |
563 } | |
564 | |
2307 | 565 if (ngx_strncmp(name->data, "cookie_", 7) == 0) { |
566 | |
2359
4fee4ebbfb0b
$cookie_... variable did not for SSI and perl
Igor Sysoev <igor@sysoev.ru>
parents:
2333
diff
changeset
|
567 if (ngx_http_variable_cookie(r, vv, (uintptr_t) name) == NGX_OK) { |
2307 | 568 return vv; |
569 } | |
570 | |
571 return NULL; | |
572 } | |
573 | |
2137 | 574 if (ngx_strncmp(name->data, "arg_", 4) == 0) { |
575 | |
576 if (ngx_http_variable_argument(r, vv, (uintptr_t) name) == NGX_OK) { | |
577 return vv; | |
578 } | |
579 | |
580 return NULL; | |
581 } | |
582 | |
635 | 583 vv->not_found = 1; |
573 | 584 |
501 | 585 return vv; |
499 | 586 } |
587 | |
588 | |
573 | 589 static ngx_int_t |
590 ngx_http_variable_request(ngx_http_request_t *r, ngx_http_variable_value_t *v, | |
591 uintptr_t data) | |
592 { | |
593 ngx_str_t *s; | |
594 | |
595 s = (ngx_str_t *) ((char *) r + data); | |
596 | |
597 if (s->data) { | |
598 v->len = s->len; | |
599 v->valid = 1; | |
1565 | 600 v->no_cacheable = 0; |
573 | 601 v->not_found = 0; |
602 v->data = s->data; | |
603 | |
604 } else { | |
605 v->not_found = 1; | |
606 } | |
607 | |
608 return NGX_OK; | |
609 } | |
610 | |
611 | |
637 | 612 static void |
1350 | 613 ngx_http_variable_request_set(ngx_http_request_t *r, |
614 ngx_http_variable_value_t *v, uintptr_t data) | |
615 { | |
616 ngx_str_t *s; | |
617 | |
618 s = (ngx_str_t *) ((char *) r + data); | |
619 | |
620 s->len = v->len; | |
621 s->data = v->data; | |
622 } | |
623 | |
624 | |
3282
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
625 static ngx_int_t |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
626 ngx_http_variable_request_get_size(ngx_http_request_t *r, |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
627 ngx_http_variable_value_t *v, uintptr_t data) |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
628 { |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
629 size_t *sp; |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
630 |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
631 sp = (size_t *) ((char *) r + data); |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
632 |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
633 v->data = ngx_pnalloc(r->pool, NGX_SIZE_T_LEN); |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
634 if (v->data == NULL) { |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
635 return NGX_ERROR; |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
636 } |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
637 |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
638 v->len = ngx_sprintf(v->data, "%uz", *sp) - v->data; |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
639 v->valid = 1; |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
640 v->no_cacheable = 0; |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
641 v->not_found = 0; |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
642 |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
643 return NGX_OK; |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
644 } |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
645 |
c76b7a7959d5
fix segfault if $limit_rate was logged
Igor Sysoev <igor@sysoev.ru>
parents:
3268
diff
changeset
|
646 |
1350 | 647 static void |
637 | 648 ngx_http_variable_request_set_size(ngx_http_request_t *r, |
649 ngx_http_variable_value_t *v, uintptr_t data) | |
650 { | |
651 ssize_t s, *sp; | |
652 ngx_str_t val; | |
653 | |
1310
33d6c994a0b2
Sun Studio on sparc uses different bit order
Igor Sysoev <igor@sysoev.ru>
parents:
1191
diff
changeset
|
654 val.len = v->len; |
637 | 655 val.data = v->data; |
656 | |
657 s = ngx_parse_size(&val); | |
658 | |
659 if (s == NGX_ERROR) { | |
660 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0, | |
661 "invalid size \"%V\"", &val); | |
662 return; | |
663 } | |
664 | |
665 sp = (ssize_t *) ((char *) r + data); | |
666 | |
667 *sp = s; | |
668 | |
669 return; | |
670 } | |
671 | |
672 | |
573 | 673 static ngx_int_t |
674 ngx_http_variable_header(ngx_http_request_t *r, ngx_http_variable_value_t *v, | |
675 uintptr_t data) | |
515 | 676 { |
573 | 677 ngx_table_elt_t *h; |
678 | |
679 h = *(ngx_table_elt_t **) ((char *) r + data); | |
680 | |
681 if (h) { | |
682 v->len = h->value.len; | |
683 v->valid = 1; | |
1565 | 684 v->no_cacheable = 0; |
573 | 685 v->not_found = 0; |
686 v->data = h->value.data; | |
687 | |
688 } else { | |
689 v->not_found = 1; | |
690 } | |
691 | |
692 return NGX_OK; | |
693 } | |
694 | |
695 | |
696 static ngx_int_t | |
697 ngx_http_variable_headers(ngx_http_request_t *r, ngx_http_variable_value_t *v, | |
698 uintptr_t data) | |
699 { | |
4334
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
700 size_t len; |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
701 u_char *p, *end; |
667 | 702 ngx_uint_t i, n; |
573 | 703 ngx_array_t *a; |
704 ngx_table_elt_t **h; | |
515 | 705 |
706 a = (ngx_array_t *) ((char *) r + data); | |
707 | |
667 | 708 n = a->nelts; |
4334
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
709 h = a->elts; |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
710 |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
711 len = 0; |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
712 |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
713 for (i = 0; i < n; i++) { |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
714 |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
715 if (h[i]->hash == 0) { |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
716 continue; |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
717 } |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
718 |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
719 len += h[i]->value.len + sizeof("; ") - 1; |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
720 } |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
721 |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
722 if (len == 0) { |
573 | 723 v->not_found = 1; |
724 return NGX_OK; | |
515 | 725 } |
726 | |
4334
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
727 len -= sizeof("; ") - 1; |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
728 |
573 | 729 v->valid = 1; |
1565 | 730 v->no_cacheable = 0; |
573 | 731 v->not_found = 0; |
515 | 732 |
667 | 733 if (n == 1) { |
573 | 734 v->len = (*h)->value.len; |
735 v->data = (*h)->value.data; | |
515 | 736 |
573 | 737 return NGX_OK; |
515 | 738 } |
739 | |
2049 | 740 p = ngx_pnalloc(r->pool, len); |
573 | 741 if (p == NULL) { |
742 return NGX_ERROR; | |
743 } | |
744 | |
745 v->len = len; | |
746 v->data = p; | |
515 | 747 |
4334
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
748 end = p + len; |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
749 |
515 | 750 for (i = 0; /* void */ ; i++) { |
4334
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
751 |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
752 if (h[i]->hash == 0) { |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
753 continue; |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
754 } |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
755 |
573 | 756 p = ngx_copy(p, h[i]->value.data, h[i]->value.len); |
515 | 757 |
4334
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
758 if (p == end) { |
515 | 759 break; |
760 } | |
761 | |
762 *p++ = ';'; *p++ = ' '; | |
763 } | |
764 | |
573 | 765 return NGX_OK; |
515 | 766 } |
767 | |
768 | |
573 | 769 static ngx_int_t |
577 | 770 ngx_http_variable_unknown_header_in(ngx_http_request_t *r, |
771 ngx_http_variable_value_t *v, uintptr_t data) | |
772 { | |
773 return ngx_http_variable_unknown_header(v, (ngx_str_t *) data, | |
774 &r->headers_in.headers.part, | |
775 sizeof("http_") - 1); | |
776 } | |
777 | |
778 | |
779 static ngx_int_t | |
780 ngx_http_variable_unknown_header_out(ngx_http_request_t *r, | |
573 | 781 ngx_http_variable_value_t *v, uintptr_t data) |
499 | 782 { |
577 | 783 return ngx_http_variable_unknown_header(v, (ngx_str_t *) data, |
784 &r->headers_out.headers.part, | |
785 sizeof("sent_http_") - 1); | |
786 } | |
501 | 787 |
577 | 788 |
1162 | 789 ngx_int_t |
577 | 790 ngx_http_variable_unknown_header(ngx_http_variable_value_t *v, ngx_str_t *var, |
791 ngx_list_part_t *part, size_t prefix) | |
792 { | |
573 | 793 u_char ch; |
794 ngx_uint_t i, n; | |
795 ngx_table_elt_t *header; | |
499 | 796 |
797 header = part->elts; | |
798 | |
799 for (i = 0; /* void */ ; i++) { | |
800 | |
801 if (i >= part->nelts) { | |
802 if (part->next == NULL) { | |
803 break; | |
804 } | |
805 | |
806 part = part->next; | |
807 header = part->elts; | |
808 i = 0; | |
809 } | |
810 | |
4334
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
811 if (header[i].hash == 0) { |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
812 continue; |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
813 } |
f8881d301d62
Fixed: some of $sent_http_* variables may contain header entries that actually
Valentin Bartenev <vbart@nginx.com>
parents:
4332
diff
changeset
|
814 |
577 | 815 for (n = 0; n + prefix < var->len && n < header[i].key.len; n++) { |
499 | 816 ch = header[i].key.data[n]; |
817 | |
509 | 818 if (ch >= 'A' && ch <= 'Z') { |
819 ch |= 0x20; | |
499 | 820 |
821 } else if (ch == '-') { | |
822 ch = '_'; | |
823 } | |
824 | |
577 | 825 if (var->data[n + prefix] != ch) { |
499 | 826 break; |
827 } | |
828 } | |
829 | |
742
75d767d32624
nonexistent $sent_http_content has value of $sent_http_content_length or so
Igor Sysoev <igor@sysoev.ru>
parents:
732
diff
changeset
|
830 if (n + prefix == var->len && n == header[i].key.len) { |
573 | 831 v->len = header[i].value.len; |
832 v->valid = 1; | |
1565 | 833 v->no_cacheable = 0; |
573 | 834 v->not_found = 0; |
835 v->data = header[i].value.data; | |
499 | 836 |
573 | 837 return NGX_OK; |
499 | 838 } |
839 } | |
840 | |
573 | 841 v->not_found = 1; |
842 | |
843 return NGX_OK; | |
509 | 844 } |
845 | |
846 | |
573 | 847 static ngx_int_t |
3144
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
848 ngx_http_variable_request_line(ngx_http_request_t *r, |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
849 ngx_http_variable_value_t *v, uintptr_t data) |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
850 { |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
851 u_char *p, *s; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
852 |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
853 s = r->request_line.data; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
854 |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
855 if (s == NULL) { |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
856 s = r->request_start; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
857 |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
858 if (s == NULL) { |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
859 v->not_found = 1; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
860 return NGX_OK; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
861 } |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
862 |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
863 for (p = s; p < r->header_in->last; p++) { |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
864 if (*p == CR || *p == LF) { |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
865 break; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
866 } |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
867 } |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
868 |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
869 r->request_line.len = p - s; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
870 r->request_line.data = s; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
871 } |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
872 |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
873 v->len = r->request_line.len; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
874 v->valid = 1; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
875 v->no_cacheable = 0; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
876 v->not_found = 0; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
877 v->data = s; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
878 |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
879 return NGX_OK; |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
880 } |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
881 |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
882 |
ecbfc3396c42
allow to log invalid $request in access_log always,
Igor Sysoev <igor@sysoev.ru>
parents:
2878
diff
changeset
|
883 static ngx_int_t |
2307 | 884 ngx_http_variable_cookie(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
885 uintptr_t data) | |
886 { | |
887 ngx_str_t *name = (ngx_str_t *) data; | |
888 | |
889 ngx_str_t cookie, s; | |
890 | |
891 s.len = name->len - (sizeof("cookie_") - 1); | |
892 s.data = name->data + sizeof("cookie_") - 1; | |
893 | |
894 if (ngx_http_parse_multi_header_lines(&r->headers_in.cookies, &s, &cookie) | |
895 == NGX_DECLINED) | |
896 { | |
897 v->not_found = 1; | |
898 return NGX_OK; | |
899 } | |
900 | |
901 v->len = cookie.len; | |
902 v->valid = 1; | |
903 v->no_cacheable = 0; | |
904 v->not_found = 0; | |
905 v->data = cookie.data; | |
906 | |
907 return NGX_OK; | |
908 } | |
909 | |
910 | |
911 static ngx_int_t | |
2137 | 912 ngx_http_variable_argument(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
913 uintptr_t data) | |
914 { | |
915 ngx_str_t *name = (ngx_str_t *) data; | |
916 | |
2415 | 917 u_char *arg; |
918 size_t len; | |
919 ngx_str_t value; | |
2137 | 920 |
2415 | 921 len = name->len - (sizeof("arg_") - 1); |
922 arg = name->data + sizeof("arg_") - 1; | |
923 | |
924 if (ngx_http_arg(r, arg, len, &value) != NGX_OK) { | |
2137 | 925 v->not_found = 1; |
926 return NGX_OK; | |
927 } | |
928 | |
2415 | 929 v->data = value.data; |
930 v->len = value.len; | |
931 v->valid = 1; | |
932 v->no_cacheable = 0; | |
933 v->not_found = 0; | |
2137 | 934 |
935 return NGX_OK; | |
936 } | |
937 | |
938 | |
4545
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
939 #if (NGX_HAVE_TCP_INFO) |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
940 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
941 static ngx_int_t |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
942 ngx_http_variable_tcpinfo(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
943 uintptr_t data) |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
944 { |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
945 struct tcp_info ti; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
946 socklen_t len; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
947 uint32_t value; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
948 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
949 len = sizeof(struct tcp_info); |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
950 if (getsockopt(r->connection->fd, IPPROTO_TCP, TCP_INFO, &ti, &len) == -1) { |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
951 v->not_found = 1; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
952 return NGX_OK; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
953 } |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
954 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
955 v->data = ngx_pnalloc(r->pool, NGX_INT32_LEN); |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
956 if (v->data == NULL) { |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
957 return NGX_ERROR; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
958 } |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
959 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
960 switch (data) { |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
961 case 0: |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
962 value = ti.tcpi_rtt; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
963 break; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
964 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
965 case 1: |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
966 value = ti.tcpi_rttvar; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
967 break; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
968 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
969 case 2: |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
970 value = ti.tcpi_snd_cwnd; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
971 break; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
972 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
973 case 3: |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
974 value = ti.tcpi_rcv_space; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
975 break; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
976 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
977 /* suppress warning */ |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
978 default: |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
979 value = 0; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
980 break; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
981 } |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
982 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
983 v->len = ngx_sprintf(v->data, "%uD", value) - v->data; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
984 v->valid = 1; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
985 v->no_cacheable = 0; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
986 v->not_found = 0; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
987 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
988 return NGX_OK; |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
989 } |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
990 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
991 #endif |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
992 |
ba39af7274ed
Implemented $tcpinfo_rtt, $tcpinfo_rttvar, $tcpinfo_snd_cwnd, and
Ruslan Ermilov <ru@nginx.com>
parents:
4540
diff
changeset
|
993 |
2137 | 994 static ngx_int_t |
4928
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
995 ngx_http_variable_content_length(ngx_http_request_t *r, |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
996 ngx_http_variable_value_t *v, uintptr_t data) |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
997 { |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
998 u_char *p; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
999 |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1000 if (r->headers_in.content_length) { |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1001 v->len = r->headers_in.content_length->value.len; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1002 v->data = r->headers_in.content_length->value.data; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1003 v->valid = 1; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1004 v->no_cacheable = 0; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1005 v->not_found = 0; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1006 |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1007 } else if (r->headers_in.content_length_n >= 0) { |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1008 p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN); |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1009 if (p == NULL) { |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1010 return NGX_ERROR; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1011 } |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1012 |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1013 v->len = ngx_sprintf(p, "%O", r->headers_in.content_length_n) - p; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1014 v->data = p; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1015 v->valid = 1; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1016 v->no_cacheable = 0; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1017 v->not_found = 0; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1018 |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1019 } else { |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1020 v->not_found = 1; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1021 } |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1022 |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1023 return NGX_OK; |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1024 } |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1025 |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1026 |
ec7d97006a30
Request body: $content_length variable to honor real body size.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4921
diff
changeset
|
1027 static ngx_int_t |
573 | 1028 ngx_http_variable_host(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
1029 uintptr_t data) | |
509 | 1030 { |
1811 | 1031 ngx_http_core_srv_conf_t *cscf; |
1032 | |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
1033 if (r->headers_in.server.len) { |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
1034 v->len = r->headers_in.server.len; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
1035 v->data = r->headers_in.server.data; |
928
a6fe6bedb9e3
fix segfault when $host is used and
Igor Sysoev <igor@sysoev.ru>
parents:
864
diff
changeset
|
1036 |
a6fe6bedb9e3
fix segfault when $host is used and
Igor Sysoev <igor@sysoev.ru>
parents:
864
diff
changeset
|
1037 } else { |
2007
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
1038 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
1039 |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
1040 v->len = cscf->server_name.len; |
b9de93d804ea
*) host in request line has priority
Igor Sysoev <igor@sysoev.ru>
parents:
1811
diff
changeset
|
1041 v->data = cscf->server_name.data; |
509 | 1042 } |
1043 | |
573 | 1044 v->valid = 1; |
1565 | 1045 v->no_cacheable = 0; |
573 | 1046 v->not_found = 0; |
509 | 1047 |
573 | 1048 return NGX_OK; |
499 | 1049 } |
1050 | |
1051 | |
573 | 1052 static ngx_int_t |
983
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1053 ngx_http_variable_binary_remote_addr(ngx_http_request_t *r, |
573 | 1054 ngx_http_variable_value_t *v, uintptr_t data) |
499 | 1055 { |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1056 struct sockaddr_in *sin; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1057 #if (NGX_HAVE_INET6) |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1058 struct sockaddr_in6 *sin6; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1059 #endif |
982 | 1060 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1061 switch (r->connection->sockaddr->sa_family) { |
983
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1062 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1063 #if (NGX_HAVE_INET6) |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1064 case AF_INET6: |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1065 sin6 = (struct sockaddr_in6 *) r->connection->sockaddr; |
982 | 1066 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1067 v->len = sizeof(struct in6_addr); |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1068 v->valid = 1; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1069 v->no_cacheable = 0; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1070 v->not_found = 0; |
3268
c6a40c815d45
use sin6_addr.s6_addr instead of "(u_char *) & .sin6_addr"
Igor Sysoev <igor@sysoev.ru>
parents:
3144
diff
changeset
|
1071 v->data = sin6->sin6_addr.s6_addr; |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1072 |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1073 break; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1074 #endif |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1075 |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1076 default: /* AF_INET */ |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1077 sin = (struct sockaddr_in *) r->connection->sockaddr; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1078 |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1079 v->len = sizeof(in_addr_t); |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1080 v->valid = 1; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1081 v->no_cacheable = 0; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1082 v->not_found = 0; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1083 v->data = (u_char *) &sin->sin_addr; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1084 |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1085 break; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1086 } |
982 | 1087 |
983
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1088 return NGX_OK; |
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1089 } |
982 | 1090 |
1091 | |
983
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1092 static ngx_int_t |
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1093 ngx_http_variable_remote_addr(ngx_http_request_t *r, |
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1094 ngx_http_variable_value_t *v, uintptr_t data) |
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1095 { |
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1096 v->len = r->connection->addr_text.len; |
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1097 v->valid = 1; |
1565 | 1098 v->no_cacheable = 0; |
983
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1099 v->not_found = 0; |
7a8ca436d611
ngx_http_variable_binary_remote_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
982
diff
changeset
|
1100 v->data = r->connection->addr_text.data; |
499 | 1101 |
573 | 1102 return NGX_OK; |
499 | 1103 } |
1104 | |
1105 | |
573 | 1106 static ngx_int_t |
1107 ngx_http_variable_remote_port(ngx_http_request_t *r, | |
1108 ngx_http_variable_value_t *v, uintptr_t data) | |
499 | 1109 { |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1110 ngx_uint_t port; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1111 struct sockaddr_in *sin; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1112 #if (NGX_HAVE_INET6) |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1113 struct sockaddr_in6 *sin6; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1114 #endif |
509 | 1115 |
573 | 1116 v->len = 0; |
1117 v->valid = 1; | |
1565 | 1118 v->no_cacheable = 0; |
573 | 1119 v->not_found = 0; |
509 | 1120 |
2049 | 1121 v->data = ngx_pnalloc(r->pool, sizeof("65535") - 1); |
573 | 1122 if (v->data == NULL) { |
1123 return NGX_ERROR; | |
509 | 1124 } |
1125 | |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1126 switch (r->connection->sockaddr->sa_family) { |
577 | 1127 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1128 #if (NGX_HAVE_INET6) |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1129 case AF_INET6: |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1130 sin6 = (struct sockaddr_in6 *) r->connection->sockaddr; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1131 port = ntohs(sin6->sin6_port); |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1132 break; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1133 #endif |
577 | 1134 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1135 default: /* AF_INET */ |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1136 sin = (struct sockaddr_in *) r->connection->sockaddr; |
509 | 1137 port = ntohs(sin->sin_port); |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1138 break; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1139 } |
577 | 1140 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1141 if (port > 0 && port < 65536) { |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1142 v->len = ngx_sprintf(v->data, "%ui", port) - v->data; |
509 | 1143 } |
1144 | |
573 | 1145 return NGX_OK; |
509 | 1146 } |
1147 | |
1148 | |
573 | 1149 static ngx_int_t |
1150 ngx_http_variable_server_addr(ngx_http_request_t *r, | |
1151 ngx_http_variable_value_t *v, uintptr_t data) | |
509 | 1152 { |
1805 | 1153 ngx_str_t s; |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1154 u_char addr[NGX_SOCKADDR_STRLEN]; |
499 | 1155 |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1156 s.len = NGX_SOCKADDR_STRLEN; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1157 s.data = addr; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1158 |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2844
diff
changeset
|
1159 if (ngx_connection_local_sockaddr(r->connection, &s, 0) != NGX_OK) { |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1160 return NGX_ERROR; |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1161 } |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1162 |
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1163 s.data = ngx_pnalloc(r->pool, s.len); |
1805 | 1164 if (s.data == NULL) { |
573 | 1165 return NGX_ERROR; |
509 | 1166 } |
1167 | |
2512
2e91aecb9e57
a prelimiary IPv6 support, HTTP listen
Igor Sysoev <igor@sysoev.ru>
parents:
2485
diff
changeset
|
1168 ngx_memcpy(s.data, addr, s.len); |
509 | 1169 |
1805 | 1170 v->len = s.len; |
573 | 1171 v->valid = 1; |
1565 | 1172 v->no_cacheable = 0; |
573 | 1173 v->not_found = 0; |
1805 | 1174 v->data = s.data; |
499 | 1175 |
573 | 1176 return NGX_OK; |
499 | 1177 } |
1178 | |
1179 | |
573 | 1180 static ngx_int_t |
1181 ngx_http_variable_server_port(ngx_http_request_t *r, | |
1182 ngx_http_variable_value_t *v, uintptr_t data) | |
509 | 1183 { |
2533 | 1184 ngx_uint_t port; |
1185 struct sockaddr_in *sin; | |
1186 #if (NGX_HAVE_INET6) | |
1187 struct sockaddr_in6 *sin6; | |
1188 #endif | |
1189 | |
1190 v->len = 0; | |
573 | 1191 v->valid = 1; |
1565 | 1192 v->no_cacheable = 0; |
573 | 1193 v->not_found = 0; |
2533 | 1194 |
2857
507fc5ac9839
use ngx_connection_local_sockaddr() instead of ngx_http_server_addr()
Igor Sysoev <igor@sysoev.ru>
parents:
2844
diff
changeset
|
1195 if (ngx_connection_local_sockaddr(r->connection, NULL, 0) != NGX_OK) { |
2533 | 1196 return NGX_ERROR; |
1197 } | |
1198 | |
1199 v->data = ngx_pnalloc(r->pool, sizeof("65535") - 1); | |
1200 if (v->data == NULL) { | |
1201 return NGX_ERROR; | |
1202 } | |
1203 | |
1204 switch (r->connection->local_sockaddr->sa_family) { | |
1205 | |
1206 #if (NGX_HAVE_INET6) | |
1207 case AF_INET6: | |
1208 sin6 = (struct sockaddr_in6 *) r->connection->local_sockaddr; | |
1209 port = ntohs(sin6->sin6_port); | |
1210 break; | |
1211 #endif | |
1212 | |
1213 default: /* AF_INET */ | |
1214 sin = (struct sockaddr_in *) r->connection->local_sockaddr; | |
1215 port = ntohs(sin->sin_port); | |
1216 break; | |
1217 } | |
1218 | |
1219 if (port > 0 && port < 65536) { | |
1220 v->len = ngx_sprintf(v->data, "%ui", port) - v->data; | |
1221 } | |
509 | 1222 |
573 | 1223 return NGX_OK; |
509 | 1224 } |
1225 | |
1226 | |
573 | 1227 static ngx_int_t |
731 | 1228 ngx_http_variable_scheme(ngx_http_request_t *r, |
1229 ngx_http_variable_value_t *v, uintptr_t data) | |
1230 { | |
1231 #if (NGX_HTTP_SSL) | |
1232 | |
1233 if (r->connection->ssl) { | |
1234 v->len = sizeof("https") - 1; | |
1235 v->valid = 1; | |
1565 | 1236 v->no_cacheable = 0; |
731 | 1237 v->not_found = 0; |
732 | 1238 v->data = (u_char *) "https"; |
731 | 1239 |
1240 return NGX_OK; | |
1241 } | |
1242 | |
1243 #endif | |
1244 | |
1245 v->len = sizeof("http") - 1; | |
1246 v->valid = 1; | |
1565 | 1247 v->no_cacheable = 0; |
731 | 1248 v->not_found = 0; |
732 | 1249 v->data = (u_char *) "http"; |
731 | 1250 |
1251 return NGX_OK; | |
1252 } | |
1253 | |
1254 | |
1255 static ngx_int_t | |
4332
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1256 ngx_http_variable_https(ngx_http_request_t *r, |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1257 ngx_http_variable_value_t *v, uintptr_t data) |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1258 { |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1259 #if (NGX_HTTP_SSL) |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1260 |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1261 if (r->connection->ssl) { |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1262 v->len = sizeof("on") - 1; |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1263 v->valid = 1; |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1264 v->no_cacheable = 0; |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1265 v->not_found = 0; |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1266 v->data = (u_char *) "on"; |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1267 |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1268 return NGX_OK; |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1269 } |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1270 |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1271 #endif |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1272 |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1273 *v = ngx_http_variable_null_value; |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1274 |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1275 return NGX_OK; |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1276 } |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1277 |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1278 |
4d9f985fd217
Added the $https variable.
Valentin Bartenev <vbart@nginx.com>
parents:
3929
diff
changeset
|
1279 static ngx_int_t |
1351 | 1280 ngx_http_variable_is_args(ngx_http_request_t *r, |
1281 ngx_http_variable_value_t *v, uintptr_t data) | |
1282 { | |
1283 v->valid = 1; | |
1565 | 1284 v->no_cacheable = 0; |
1351 | 1285 v->not_found = 0; |
1286 | |
1287 if (r->args.len == 0) { | |
1288 v->len = 0; | |
1289 v->data = NULL; | |
1290 return NGX_OK; | |
1291 } | |
1292 | |
1293 v->len = 1; | |
1294 v->data = (u_char *) "?"; | |
1295 | |
1296 return NGX_OK; | |
1297 } | |
1298 | |
1299 | |
1300 static ngx_int_t | |
573 | 1301 ngx_http_variable_document_root(ngx_http_request_t *r, |
1302 ngx_http_variable_value_t *v, uintptr_t data) | |
499 | 1303 { |
671 | 1304 ngx_str_t path; |
573 | 1305 ngx_http_core_loc_conf_t *clcf; |
509 | 1306 |
1307 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
1308 | |
671 | 1309 if (clcf->root_lengths == NULL) { |
1310 v->len = clcf->root.len; | |
1311 v->valid = 1; | |
1565 | 1312 v->no_cacheable = 0; |
671 | 1313 v->not_found = 0; |
1314 v->data = clcf->root.data; | |
1315 | |
1316 } else { | |
1317 if (ngx_http_script_run(r, &path, clcf->root_lengths->elts, 0, | |
1318 clcf->root_values->elts) | |
1319 == NULL) | |
1320 { | |
1321 return NGX_ERROR; | |
1322 } | |
1323 | |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2533
diff
changeset
|
1324 if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &path, 0) != NGX_OK) { |
671 | 1325 return NGX_ERROR; |
1326 } | |
1327 | |
1328 v->len = path.len; | |
1329 v->valid = 1; | |
1565 | 1330 v->no_cacheable = 0; |
671 | 1331 v->not_found = 0; |
1332 v->data = path.data; | |
1333 } | |
509 | 1334 |
573 | 1335 return NGX_OK; |
509 | 1336 } |
1337 | |
1338 | |
573 | 1339 static ngx_int_t |
2259 | 1340 ngx_http_variable_realpath_root(ngx_http_request_t *r, |
1341 ngx_http_variable_value_t *v, uintptr_t data) | |
1342 { | |
4558
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1343 u_char *real; |
2259 | 1344 size_t len; |
1345 ngx_str_t path; | |
1346 ngx_http_core_loc_conf_t *clcf; | |
4558
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1347 #if (NGX_HAVE_MAX_PATH) |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1348 u_char buffer[NGX_MAX_PATH]; |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1349 #endif |
2259 | 1350 |
1351 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
1352 | |
1353 if (clcf->root_lengths == NULL) { | |
1354 path = clcf->root; | |
1355 | |
1356 } else { | |
1357 if (ngx_http_script_run(r, &path, clcf->root_lengths->elts, 1, | |
1358 clcf->root_values->elts) | |
1359 == NULL) | |
1360 { | |
1361 return NGX_ERROR; | |
1362 } | |
1363 | |
1364 path.data[path.len - 1] = '\0'; | |
1365 | |
2536
a6d6d762c554
small optimization: " == NGX_ERROR" > " != NGX_OK"
Igor Sysoev <igor@sysoev.ru>
parents:
2533
diff
changeset
|
1366 if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &path, 0) != NGX_OK) { |
2259 | 1367 return NGX_ERROR; |
1368 } | |
1369 } | |
1370 | |
4558
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1371 #if (NGX_HAVE_MAX_PATH) |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1372 real = buffer; |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1373 #else |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1374 real = NULL; |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1375 #endif |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1376 |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1377 real = ngx_realpath(path.data, real); |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1378 |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1379 if (real == NULL) { |
2259 | 1380 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno, |
1381 ngx_realpath_n " \"%s\" failed", path.data); | |
1382 return NGX_ERROR; | |
1383 } | |
1384 | |
1385 len = ngx_strlen(real); | |
1386 | |
1387 v->data = ngx_pnalloc(r->pool, len); | |
1388 if (v->data == NULL) { | |
4558
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1389 #if !(NGX_HAVE_MAX_PATH) |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1390 ngx_free(real); |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1391 #endif |
2259 | 1392 return NGX_ERROR; |
1393 } | |
1394 | |
1395 v->len = len; | |
1396 v->valid = 1; | |
1397 v->no_cacheable = 0; | |
1398 v->not_found = 0; | |
1399 | |
1400 ngx_memcpy(v->data, real, len); | |
1401 | |
4558
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1402 #if !(NGX_HAVE_MAX_PATH) |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1403 ngx_free(real); |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1404 #endif |
8865fd1f3aa5
Fixed unconditional MAX_PATH usage (ticket #22).
Maxim Dounin <mdounin@mdounin.ru>
parents:
4545
diff
changeset
|
1405 |
2259 | 1406 return NGX_OK; |
1407 } | |
1408 | |
1409 | |
1410 static ngx_int_t | |
573 | 1411 ngx_http_variable_request_filename(ngx_http_request_t *r, |
1412 ngx_http_variable_value_t *v, uintptr_t data) | |
509 | 1413 { |
773 | 1414 size_t root; |
573 | 1415 ngx_str_t path; |
499 | 1416 |
773 | 1417 if (ngx_http_map_uri_to_path(r, &path, &root, 0) == NULL) { |
573 | 1418 return NGX_ERROR; |
557 | 1419 } |
509 | 1420 |
557 | 1421 /* ngx_http_map_uri_to_path() allocates memory for terminating '\0' */ |
509 | 1422 |
573 | 1423 v->len = path.len - 1; |
1424 v->valid = 1; | |
1565 | 1425 v->no_cacheable = 0; |
573 | 1426 v->not_found = 0; |
1427 v->data = path.data; | |
499 | 1428 |
573 | 1429 return NGX_OK; |
499 | 1430 } |
1431 | |
1432 | |
573 | 1433 static ngx_int_t |
1811 | 1434 ngx_http_variable_server_name(ngx_http_request_t *r, |
1435 ngx_http_variable_value_t *v, uintptr_t data) | |
1436 { | |
1437 ngx_http_core_srv_conf_t *cscf; | |
1438 | |
1439 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module); | |
1440 | |
1441 v->len = cscf->server_name.len; | |
1442 v->valid = 1; | |
1443 v->no_cacheable = 0; | |
1444 v->not_found = 0; | |
1445 v->data = cscf->server_name.data; | |
1446 | |
1447 return NGX_OK; | |
1448 } | |
1449 | |
1450 | |
1451 static ngx_int_t | |
573 | 1452 ngx_http_variable_request_method(ngx_http_request_t *r, |
1453 ngx_http_variable_value_t *v, uintptr_t data) | |
561 | 1454 { |
647 | 1455 if (r->main->method_name.data) { |
1456 v->len = r->main->method_name.len; | |
573 | 1457 v->valid = 1; |
1565 | 1458 v->no_cacheable = 0; |
573 | 1459 v->not_found = 0; |
647 | 1460 v->data = r->main->method_name.data; |
573 | 1461 |
1462 } else { | |
1463 v->not_found = 1; | |
561 | 1464 } |
1465 | |
573 | 1466 return NGX_OK; |
561 | 1467 } |
1468 | |
1469 | |
573 | 1470 static ngx_int_t |
1471 ngx_http_variable_remote_user(ngx_http_request_t *r, | |
1472 ngx_http_variable_value_t *v, uintptr_t data) | |
539 | 1473 { |
573 | 1474 ngx_int_t rc; |
539 | 1475 |
1476 rc = ngx_http_auth_basic_user(r); | |
1477 | |
1478 if (rc == NGX_DECLINED) { | |
573 | 1479 v->not_found = 1; |
1480 return NGX_OK; | |
539 | 1481 } |
1482 | |
1483 if (rc == NGX_ERROR) { | |
573 | 1484 return NGX_ERROR; |
539 | 1485 } |
1486 | |
573 | 1487 v->len = r->headers_in.user.len; |
1488 v->valid = 1; | |
1565 | 1489 v->no_cacheable = 0; |
573 | 1490 v->not_found = 0; |
1491 v->data = r->headers_in.user.data; | |
571 | 1492 |
573 | 1493 return NGX_OK; |
571 | 1494 } |
1495 | |
1496 | |
611 | 1497 static ngx_int_t |
4886 | 1498 ngx_http_variable_bytes_sent(ngx_http_request_t *r, |
1499 ngx_http_variable_value_t *v, uintptr_t data) | |
1500 { | |
1501 u_char *p; | |
1502 | |
1503 p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN); | |
1504 if (p == NULL) { | |
1505 return NGX_ERROR; | |
1506 } | |
1507 | |
1508 v->len = ngx_sprintf(p, "%O", r->connection->sent) - p; | |
1509 v->valid = 1; | |
1510 v->no_cacheable = 0; | |
1511 v->not_found = 0; | |
1512 v->data = p; | |
1513 | |
1514 return NGX_OK; | |
1515 } | |
1516 | |
1517 | |
1518 static ngx_int_t | |
611 | 1519 ngx_http_variable_body_bytes_sent(ngx_http_request_t *r, |
1520 ngx_http_variable_value_t *v, uintptr_t data) | |
1521 { | |
1522 off_t sent; | |
1523 u_char *p; | |
1524 | |
1525 sent = r->connection->sent - r->header_size; | |
1526 | |
1527 if (sent < 0) { | |
1528 sent = 0; | |
1529 } | |
1530 | |
2049 | 1531 p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN); |
611 | 1532 if (p == NULL) { |
1533 return NGX_ERROR; | |
1534 } | |
1535 | |
1536 v->len = ngx_sprintf(p, "%O", sent) - p; | |
1537 v->valid = 1; | |
1565 | 1538 v->no_cacheable = 0; |
611 | 1539 v->not_found = 0; |
1540 v->data = p; | |
1541 | |
1542 return NGX_OK; | |
1543 } | |
1544 | |
1545 | |
629 | 1546 static ngx_int_t |
4685
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1547 ngx_http_variable_status(ngx_http_request_t *r, |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1548 ngx_http_variable_value_t *v, uintptr_t data) |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1549 { |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1550 ngx_uint_t status; |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1551 |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1552 v->data = ngx_pnalloc(r->pool, NGX_INT_T_LEN); |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1553 if (v->data == NULL) { |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1554 return NGX_ERROR; |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1555 } |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1556 |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1557 if (r->err_status) { |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1558 status = r->err_status; |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1559 |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1560 } else if (r->headers_out.status) { |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1561 status = r->headers_out.status; |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1562 |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1563 } else if (r->http_version == NGX_HTTP_VERSION_9) { |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1564 status = 9; |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1565 |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1566 } else { |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1567 status = 0; |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1568 } |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1569 |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1570 v->len = ngx_sprintf(v->data, "%03ui", status) - v->data; |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1571 v->valid = 1; |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1572 v->no_cacheable = 0; |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1573 v->not_found = 0; |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1574 |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1575 return NGX_OK; |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1576 } |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1577 |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1578 |
956edecaedeb
New core variable: $status.
Andrey Belov <defan@nginx.com>
parents:
4641
diff
changeset
|
1579 static ngx_int_t |
641 | 1580 ngx_http_variable_sent_content_type(ngx_http_request_t *r, |
1581 ngx_http_variable_value_t *v, uintptr_t data) | |
1582 { | |
1583 if (r->headers_out.content_type.len) { | |
1584 v->len = r->headers_out.content_type.len; | |
1585 v->valid = 1; | |
1565 | 1586 v->no_cacheable = 0; |
641 | 1587 v->not_found = 0; |
1588 v->data = r->headers_out.content_type.data; | |
1589 | |
1590 } else { | |
1591 v->not_found = 1; | |
1592 } | |
1593 | |
1594 return NGX_OK; | |
1595 } | |
1596 | |
1597 | |
1598 static ngx_int_t | |
1599 ngx_http_variable_sent_content_length(ngx_http_request_t *r, | |
1600 ngx_http_variable_value_t *v, uintptr_t data) | |
1601 { | |
1602 u_char *p; | |
1603 | |
1604 if (r->headers_out.content_length) { | |
1605 v->len = r->headers_out.content_length->value.len; | |
1606 v->valid = 1; | |
1565 | 1607 v->no_cacheable = 0; |
641 | 1608 v->not_found = 0; |
1609 v->data = r->headers_out.content_length->value.data; | |
1610 | |
1611 return NGX_OK; | |
1612 } | |
1613 | |
1614 if (r->headers_out.content_length_n >= 0) { | |
2049 | 1615 p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN); |
641 | 1616 if (p == NULL) { |
1617 return NGX_ERROR; | |
1618 } | |
1619 | |
1620 v->len = ngx_sprintf(p, "%O", r->headers_out.content_length_n) - p; | |
1621 v->valid = 1; | |
1565 | 1622 v->no_cacheable = 0; |
641 | 1623 v->not_found = 0; |
1624 v->data = p; | |
1625 | |
1626 return NGX_OK; | |
1627 } | |
1628 | |
1629 v->not_found = 1; | |
1630 | |
1631 return NGX_OK; | |
1632 } | |
1633 | |
1634 | |
1635 static ngx_int_t | |
2485
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1636 ngx_http_variable_sent_location(ngx_http_request_t *r, |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1637 ngx_http_variable_value_t *v, uintptr_t data) |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1638 { |
2539
051e9b12428e
fix segfault introduced in r2486 in $sent_http_location processing
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
1639 ngx_str_t name; |
051e9b12428e
fix segfault introduced in r2486 in $sent_http_location processing
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
1640 |
2485
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1641 if (r->headers_out.location) { |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1642 v->len = r->headers_out.location->value.len; |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1643 v->valid = 1; |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1644 v->no_cacheable = 0; |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1645 v->not_found = 0; |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1646 v->data = r->headers_out.location->value.data; |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1647 |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1648 return NGX_OK; |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1649 } |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1650 |
3516
dd1570b6f237
ngx_str_set() and ngx_str_null()
Igor Sysoev <igor@sysoev.ru>
parents:
3500
diff
changeset
|
1651 ngx_str_set(&name, "sent_http_location"); |
2539
051e9b12428e
fix segfault introduced in r2486 in $sent_http_location processing
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
1652 |
051e9b12428e
fix segfault introduced in r2486 in $sent_http_location processing
Igor Sysoev <igor@sysoev.ru>
parents:
2536
diff
changeset
|
1653 return ngx_http_variable_unknown_header(v, &name, |
2485
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1654 &r->headers_out.headers.part, |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1655 sizeof("sent_http_") - 1); |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1656 } |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1657 |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1658 |
51b1097dbb67
fix $sent_http_location for local redirects
Igor Sysoev <igor@sysoev.ru>
parents:
2415
diff
changeset
|
1659 static ngx_int_t |
641 | 1660 ngx_http_variable_sent_last_modified(ngx_http_request_t *r, |
1661 ngx_http_variable_value_t *v, uintptr_t data) | |
1662 { | |
1663 u_char *p; | |
1664 | |
1665 if (r->headers_out.last_modified) { | |
1666 v->len = r->headers_out.last_modified->value.len; | |
1667 v->valid = 1; | |
1565 | 1668 v->no_cacheable = 0; |
641 | 1669 v->not_found = 0; |
1670 v->data = r->headers_out.last_modified->value.data; | |
1671 | |
1672 return NGX_OK; | |
1673 } | |
1674 | |
1675 if (r->headers_out.last_modified_time >= 0) { | |
2049 | 1676 p = ngx_pnalloc(r->pool, |
641 | 1677 sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT") - 1); |
1678 if (p == NULL) { | |
1679 return NGX_ERROR; | |
1680 } | |
1681 | |
1682 v->len = ngx_http_time(p, r->headers_out.last_modified_time) - p; | |
1683 v->valid = 1; | |
1565 | 1684 v->no_cacheable = 0; |
641 | 1685 v->not_found = 0; |
1686 v->data = p; | |
1687 | |
1688 return NGX_OK; | |
1689 } | |
1690 | |
1691 v->not_found = 1; | |
1692 | |
1693 return NGX_OK; | |
1694 } | |
1695 | |
1696 | |
1697 static ngx_int_t | |
1698 ngx_http_variable_sent_connection(ngx_http_request_t *r, | |
1699 ngx_http_variable_value_t *v, uintptr_t data) | |
1700 { | |
1701 size_t len; | |
1702 char *p; | |
1703 | |
1704 if (r->keepalive) { | |
1705 len = sizeof("keep-alive") - 1; | |
1706 p = "keep-alive"; | |
1707 | |
1708 } else { | |
1709 len = sizeof("close") - 1; | |
1710 p = "close"; | |
1711 } | |
1712 | |
1713 v->len = len; | |
1714 v->valid = 1; | |
1565 | 1715 v->no_cacheable = 0; |
641 | 1716 v->not_found = 0; |
1717 v->data = (u_char *) p; | |
1718 | |
1719 return NGX_OK; | |
1720 } | |
1721 | |
1722 | |
1723 static ngx_int_t | |
1724 ngx_http_variable_sent_keep_alive(ngx_http_request_t *r, | |
1725 ngx_http_variable_value_t *v, uintptr_t data) | |
1726 { | |
1727 u_char *p; | |
1728 ngx_http_core_loc_conf_t *clcf; | |
1729 | |
1730 if (r->keepalive) { | |
1731 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | |
1732 | |
1733 if (clcf->keepalive_header) { | |
1734 | |
2049 | 1735 p = ngx_pnalloc(r->pool, sizeof("timeout=") - 1 + NGX_TIME_T_LEN); |
641 | 1736 if (p == NULL) { |
1737 return NGX_ERROR; | |
1738 } | |
1739 | |
1740 v->len = ngx_sprintf(p, "timeout=%T", clcf->keepalive_header) - p; | |
1741 v->valid = 1; | |
1565 | 1742 v->no_cacheable = 0; |
641 | 1743 v->not_found = 0; |
1744 v->data = p; | |
1745 | |
1746 return NGX_OK; | |
1747 } | |
1748 } | |
1749 | |
1750 v->not_found = 1; | |
1751 | |
1752 return NGX_OK; | |
1753 } | |
1754 | |
1755 | |
1756 static ngx_int_t | |
1757 ngx_http_variable_sent_transfer_encoding(ngx_http_request_t *r, | |
1758 ngx_http_variable_value_t *v, uintptr_t data) | |
1759 { | |
1760 if (r->chunked) { | |
1761 v->len = sizeof("chunked") - 1; | |
1762 v->valid = 1; | |
1565 | 1763 v->no_cacheable = 0; |
641 | 1764 v->not_found = 0; |
1765 v->data = (u_char *) "chunked"; | |
1766 | |
1767 } else { | |
1768 v->not_found = 1; | |
1769 } | |
1770 | |
1771 return NGX_OK; | |
1772 } | |
1773 | |
1774 | |
1775 static ngx_int_t | |
629 | 1776 ngx_http_variable_request_completion(ngx_http_request_t *r, |
1777 ngx_http_variable_value_t *v, uintptr_t data) | |
1778 { | |
1779 if (r->request_complete) { | |
1780 v->len = 2; | |
1781 v->valid = 1; | |
1565 | 1782 v->no_cacheable = 0; |
629 | 1783 v->not_found = 0; |
1784 v->data = (u_char *) "OK"; | |
1785 | |
1786 return NGX_OK; | |
1787 } | |
1788 | |
1789 v->len = 0; | |
1790 v->valid = 1; | |
1565 | 1791 v->no_cacheable = 0; |
629 | 1792 v->not_found = 0; |
1793 v->data = (u_char *) ""; | |
1794 | |
1795 return NGX_OK; | |
1796 } | |
1797 | |
1798 | |
759 | 1799 static ngx_int_t |
2844 | 1800 ngx_http_variable_request_body(ngx_http_request_t *r, |
1801 ngx_http_variable_value_t *v, uintptr_t data) | |
1802 { | |
1803 u_char *p; | |
1804 size_t len; | |
4921
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1805 ngx_buf_t *buf; |
2844 | 1806 ngx_chain_t *cl; |
1807 | |
2878
8535736ace1a
fix segfault introduced in r2845
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
1808 if (r->request_body == NULL |
8535736ace1a
fix segfault introduced in r2845
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
1809 || r->request_body->bufs == NULL |
8535736ace1a
fix segfault introduced in r2845
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
1810 || r->request_body->temp_file) |
8535736ace1a
fix segfault introduced in r2845
Igor Sysoev <igor@sysoev.ru>
parents:
2857
diff
changeset
|
1811 { |
2844 | 1812 v->not_found = 1; |
1813 | |
1814 return NGX_OK; | |
1815 } | |
1816 | |
1817 cl = r->request_body->bufs; | |
1818 buf = cl->buf; | |
1819 | |
1820 if (cl->next == NULL) { | |
1821 v->len = buf->last - buf->pos; | |
1822 v->valid = 1; | |
1823 v->no_cacheable = 0; | |
1824 v->not_found = 0; | |
1825 v->data = buf->pos; | |
1826 | |
1827 return NGX_OK; | |
1828 } | |
1829 | |
4921
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1830 len = buf->last - buf->pos; |
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1831 cl = cl->next; |
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1832 |
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1833 for ( /* void */ ; cl; cl = cl->next) { |
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1834 buf = cl->buf; |
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1835 len += buf->last - buf->pos; |
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1836 } |
2844 | 1837 |
1838 p = ngx_pnalloc(r->pool, len); | |
1839 if (p == NULL) { | |
1840 return NGX_ERROR; | |
1841 } | |
1842 | |
1843 v->data = p; | |
4921
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1844 cl = r->request_body->bufs; |
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1845 |
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1846 for ( /* void */ ; cl; cl = cl->next) { |
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1847 buf = cl->buf; |
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1848 p = ngx_cpymem(p, buf->pos, buf->last - buf->pos); |
fbc0791bebb2
Request body: $request_body variable generalization.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4913
diff
changeset
|
1849 } |
2844 | 1850 |
1851 v->len = len; | |
1852 v->valid = 1; | |
1853 v->no_cacheable = 0; | |
1854 v->not_found = 0; | |
1855 | |
1856 return NGX_OK; | |
1857 } | |
1858 | |
1859 | |
1860 static ngx_int_t | |
759 | 1861 ngx_http_variable_request_body_file(ngx_http_request_t *r, |
1862 ngx_http_variable_value_t *v, uintptr_t data) | |
1863 { | |
1864 if (r->request_body == NULL || r->request_body->temp_file == NULL) { | |
763
0b0f3d4854c0
variable should not be found if no request body file
Igor Sysoev <igor@sysoev.ru>
parents:
759
diff
changeset
|
1865 v->not_found = 1; |
759 | 1866 |
1867 return NGX_OK; | |
1868 } | |
1869 | |
1870 v->len = r->request_body->temp_file->file.name.len; | |
1871 v->valid = 1; | |
1565 | 1872 v->no_cacheable = 0; |
759 | 1873 v->not_found = 0; |
1874 v->data = r->request_body->temp_file->file.name.data; | |
1875 | |
1876 return NGX_OK; | |
1877 } | |
1878 | |
1879 | |
1329 | 1880 static ngx_int_t |
4913
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1881 ngx_http_variable_request_time(ngx_http_request_t *r, |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1882 ngx_http_variable_value_t *v, uintptr_t data) |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1883 { |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1884 u_char *p; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1885 ngx_time_t *tp; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1886 ngx_msec_int_t ms; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1887 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1888 p = ngx_pnalloc(r->pool, NGX_TIME_T_LEN + 4); |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1889 if (p == NULL) { |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1890 return NGX_ERROR; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1891 } |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1892 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1893 tp = ngx_timeofday(); |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1894 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1895 ms = (ngx_msec_int_t) |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1896 ((tp->sec - r->start_sec) * 1000 + (tp->msec - r->start_msec)); |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1897 ms = ngx_max(ms, 0); |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1898 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1899 v->len = ngx_sprintf(p, "%T.%03M", ms / 1000, ms % 1000) - p; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1900 v->valid = 1; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1901 v->no_cacheable = 0; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1902 v->not_found = 0; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1903 v->data = p; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1904 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1905 return NGX_OK; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1906 } |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1907 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1908 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
1909 static ngx_int_t |
4893
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1910 ngx_http_variable_connection(ngx_http_request_t *r, |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1911 ngx_http_variable_value_t *v, uintptr_t data) |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1912 { |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1913 u_char *p; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1914 |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1915 p = ngx_pnalloc(r->pool, NGX_ATOMIC_T_LEN); |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1916 if (p == NULL) { |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1917 return NGX_ERROR; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1918 } |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1919 |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1920 v->len = ngx_sprintf(p, "%uA", r->connection->number) - p; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1921 v->valid = 1; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1922 v->no_cacheable = 0; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1923 v->not_found = 0; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1924 v->data = p; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1925 |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1926 return NGX_OK; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1927 } |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1928 |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1929 |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1930 static ngx_int_t |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1931 ngx_http_variable_connection_requests(ngx_http_request_t *r, |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1932 ngx_http_variable_value_t *v, uintptr_t data) |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1933 { |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1934 u_char *p; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1935 |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1936 p = ngx_pnalloc(r->pool, NGX_INT_T_LEN); |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1937 if (p == NULL) { |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1938 return NGX_ERROR; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1939 } |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1940 |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1941 v->len = ngx_sprintf(p, "%ui", r->connection->requests) - p; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1942 v->valid = 1; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1943 v->no_cacheable = 0; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1944 v->not_found = 0; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1945 v->data = p; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1946 |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1947 return NGX_OK; |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1948 } |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1949 |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1950 |
e89bd9896fea
Variables $connection and $connection_requests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4886
diff
changeset
|
1951 static ngx_int_t |
1329 | 1952 ngx_http_variable_nginx_version(ngx_http_request_t *r, |
1953 ngx_http_variable_value_t *v, uintptr_t data) | |
1954 { | |
1955 v->len = sizeof(NGINX_VERSION) - 1; | |
1956 v->valid = 1; | |
1565 | 1957 v->no_cacheable = 0; |
1329 | 1958 v->not_found = 0; |
1959 v->data = (u_char *) NGINX_VERSION; | |
1960 | |
1961 return NGX_OK; | |
1962 } | |
1963 | |
1964 | |
2011 | 1965 static ngx_int_t |
1966 ngx_http_variable_hostname(ngx_http_request_t *r, | |
1967 ngx_http_variable_value_t *v, uintptr_t data) | |
1968 { | |
1969 v->len = ngx_cycle->hostname.len; | |
1970 v->valid = 1; | |
1971 v->no_cacheable = 0; | |
1972 v->not_found = 0; | |
1973 v->data = ngx_cycle->hostname.data; | |
1974 | |
1975 return NGX_OK; | |
1976 } | |
1977 | |
1978 | |
2249 | 1979 static ngx_int_t |
1980 ngx_http_variable_pid(ngx_http_request_t *r, | |
1981 ngx_http_variable_value_t *v, uintptr_t data) | |
1982 { | |
1983 u_char *p; | |
1984 | |
1985 p = ngx_pnalloc(r->pool, NGX_INT64_LEN); | |
1986 if (p == NULL) { | |
1987 return NGX_ERROR; | |
1988 } | |
1989 | |
1990 v->len = ngx_sprintf(p, "%P", ngx_pid) - p; | |
1991 v->valid = 1; | |
1992 v->no_cacheable = 0; | |
1993 v->not_found = 0; | |
1994 v->data = p; | |
1995 | |
1996 return NGX_OK; | |
1997 } | |
1998 | |
1999 | |
4913
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2000 static ngx_int_t |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2001 ngx_http_variable_msec(ngx_http_request_t *r, |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2002 ngx_http_variable_value_t *v, uintptr_t data) |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2003 { |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2004 u_char *p; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2005 ngx_time_t *tp; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2006 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2007 p = ngx_pnalloc(r->pool, NGX_TIME_T_LEN + 4); |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2008 if (p == NULL) { |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2009 return NGX_ERROR; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2010 } |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2011 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2012 tp = ngx_timeofday(); |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2013 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2014 v->len = ngx_sprintf(p, "%T.%03M", tp->sec, tp->msec) - p; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2015 v->valid = 1; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2016 v->no_cacheable = 0; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2017 v->not_found = 0; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2018 v->data = p; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2019 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2020 return NGX_OK; |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2021 } |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2022 |
002f2c783d7c
Variables $request_time and $msec.
Ruslan Ermilov <ru@nginx.com>
parents:
4893
diff
changeset
|
2023 |
3872
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2024 void * |
3929
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2025 ngx_http_map_find(ngx_http_request_t *r, ngx_http_map_t *map, ngx_str_t *match) |
3872
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2026 { |
3929
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2027 void *value; |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2028 u_char *low; |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2029 size_t len; |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2030 ngx_uint_t key; |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2031 |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2032 len = match->len; |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2033 |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2034 if (len) { |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2035 low = ngx_pnalloc(r->pool, len); |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2036 if (low == NULL) { |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2037 return NULL; |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2038 } |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2039 |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2040 } else { |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2041 low = NULL; |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2042 } |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2043 |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2044 key = ngx_hash_strlow(low, match->data, len); |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2045 |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2046 value = ngx_hash_find_combined(&map->hash, key, low, len); |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2047 if (value) { |
fa4612bfb9fa
change ngx_http_map_find(): use case sensitive regexes
Igor Sysoev <igor@sysoev.ru>
parents:
3872
diff
changeset
|
2048 return value; |
3872
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2049 } |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2050 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2051 #if (NGX_PCRE) |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2052 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2053 if (len && map->nregex) { |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2054 ngx_int_t n; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2055 ngx_uint_t i; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2056 ngx_http_map_regex_t *reg; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2057 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2058 reg = map->regex; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2059 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2060 for (i = 0; i < map->nregex; i++) { |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2061 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2062 n = ngx_http_regex_exec(r, reg[i].regex, match); |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2063 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2064 if (n == NGX_OK) { |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2065 return reg[i].value; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2066 } |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2067 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2068 if (n == NGX_DECLINED) { |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2069 continue; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2070 } |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2071 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2072 /* NGX_ERROR */ |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2073 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2074 return NULL; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2075 } |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2076 } |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2077 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2078 #endif |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2079 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2080 return NULL; |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2081 } |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2082 |
83cd1910329c
allow regex as "map" parameter
Igor Sysoev <igor@sysoev.ru>
parents:
3641
diff
changeset
|
2083 |
3356
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3345
diff
changeset
|
2084 #if (NGX_PCRE) |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3345
diff
changeset
|
2085 |
3325 | 2086 static ngx_int_t |
2087 ngx_http_variable_not_found(ngx_http_request_t *r, ngx_http_variable_value_t *v, | |
2088 uintptr_t data) | |
2089 { | |
2090 v->not_found = 1; | |
2091 return NGX_OK; | |
2092 } | |
2093 | |
2094 | |
2095 ngx_http_regex_t * | |
2096 ngx_http_regex_compile(ngx_conf_t *cf, ngx_regex_compile_t *rc) | |
2097 { | |
2098 u_char *p; | |
2099 size_t size; | |
2100 ngx_str_t name; | |
2101 ngx_uint_t i, n; | |
2102 ngx_http_variable_t *v; | |
2103 ngx_http_regex_t *re; | |
2104 ngx_http_regex_variable_t *rv; | |
2105 ngx_http_core_main_conf_t *cmcf; | |
2106 | |
2107 rc->pool = cf->pool; | |
2108 | |
2109 if (ngx_regex_compile(rc) != NGX_OK) { | |
2110 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, "%V", &rc->err); | |
2111 return NULL; | |
2112 } | |
2113 | |
2114 re = ngx_pcalloc(cf->pool, sizeof(ngx_http_regex_t)); | |
2115 if (re == NULL) { | |
2116 return NULL; | |
2117 } | |
2118 | |
2119 re->regex = rc->regex; | |
2120 re->ncaptures = rc->captures; | |
2121 | |
2122 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); | |
2123 cmcf->ncaptures = ngx_max(cmcf->ncaptures, re->ncaptures); | |
2124 | |
2125 n = (ngx_uint_t) rc->named_captures; | |
2126 | |
2127 if (n == 0) { | |
2128 return re; | |
2129 } | |
2130 | |
2131 rv = ngx_palloc(rc->pool, n * sizeof(ngx_http_regex_variable_t)); | |
2132 if (rv == NULL) { | |
2133 return NULL; | |
2134 } | |
2135 | |
2136 re->variables = rv; | |
2137 re->nvariables = n; | |
2138 re->name = rc->pattern; | |
2139 | |
2140 size = rc->name_size; | |
2141 p = rc->names; | |
2142 | |
2143 for (i = 0; i < n; i++) { | |
2144 rv[i].capture = 2 * ((p[0] << 8) + p[1]); | |
2145 | |
2146 name.data = &p[2]; | |
2147 name.len = ngx_strlen(name.data); | |
2148 | |
2149 v = ngx_http_add_variable(cf, &name, NGX_HTTP_VAR_CHANGEABLE); | |
2150 if (v == NULL) { | |
2151 return NULL; | |
2152 } | |
2153 | |
2154 rv[i].index = ngx_http_get_variable_index(cf, &name); | |
2155 if (rv[i].index == NGX_ERROR) { | |
2156 return NULL; | |
2157 } | |
2158 | |
2159 v->get_handler = ngx_http_variable_not_found; | |
2160 | |
3409
bb79608169eb
named captures worked for two names only
Igor Sysoev <igor@sysoev.ru>
parents:
3356
diff
changeset
|
2161 p += size; |
3325 | 2162 } |
2163 | |
2164 return re; | |
2165 } | |
2166 | |
2167 | |
2168 ngx_int_t | |
2169 ngx_http_regex_exec(ngx_http_request_t *r, ngx_http_regex_t *re, ngx_str_t *s) | |
2170 { | |
2171 ngx_int_t rc, index; | |
2172 ngx_uint_t i, n, len; | |
2173 ngx_http_variable_value_t *vv; | |
2174 ngx_http_core_main_conf_t *cmcf; | |
2175 | |
2176 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module); | |
2177 | |
2178 if (re->ncaptures) { | |
3345
d8228f0b5113
evaluate maximum captures size on configuration phase
Igor Sysoev <igor@sysoev.ru>
parents:
3344
diff
changeset
|
2179 len = cmcf->ncaptures; |
3325 | 2180 |
2181 if (r->captures == NULL) { | |
2182 r->captures = ngx_palloc(r->pool, len * sizeof(int)); | |
2183 if (r->captures == NULL) { | |
2184 return NGX_ERROR; | |
2185 } | |
2186 } | |
2187 | |
2188 } else { | |
2189 len = 0; | |
2190 } | |
2191 | |
2192 rc = ngx_regex_exec(re->regex, s, r->captures, len); | |
2193 | |
2194 if (rc == NGX_REGEX_NO_MATCHED) { | |
2195 return NGX_DECLINED; | |
2196 } | |
2197 | |
2198 if (rc < 0) { | |
2199 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0, | |
2200 ngx_regex_exec_n " failed: %i on \"%V\" using \"%V\"", | |
2201 rc, s, &re->name); | |
2202 return NGX_ERROR; | |
2203 } | |
2204 | |
2205 for (i = 0; i < re->nvariables; i++) { | |
2206 | |
2207 n = re->variables[i].capture; | |
2208 index = re->variables[i].index; | |
2209 vv = &r->variables[index]; | |
2210 | |
2211 vv->len = r->captures[n + 1] - r->captures[n]; | |
2212 vv->valid = 1; | |
2213 vv->no_cacheable = 0; | |
2214 vv->not_found = 0; | |
2215 vv->data = &s->data[r->captures[n]]; | |
2216 | |
2217 #if (NGX_DEBUG) | |
2218 { | |
2219 ngx_http_variable_t *v; | |
2220 | |
2221 v = cmcf->variables.elts; | |
2222 | |
2223 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
2224 "http regex set $%V to \"%*s\"", | |
2225 &v[index].name, vv->len, vv->data); | |
2226 } | |
2227 #endif | |
2228 } | |
2229 | |
3344
1aed55182ea2
fix captures in "rewrite", the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3325
diff
changeset
|
2230 r->ncaptures = rc * 2; |
3325 | 2231 r->captures_data = s->data; |
2232 | |
2233 return NGX_OK; | |
2234 } | |
2235 | |
3356
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3345
diff
changeset
|
2236 #endif |
fe08c14530e9
fix building without PCRE, the bug had been introduced in r3326
Igor Sysoev <igor@sysoev.ru>
parents:
3345
diff
changeset
|
2237 |
3325 | 2238 |
499 | 2239 ngx_int_t |
509 | 2240 ngx_http_variables_add_core_vars(ngx_conf_t *cf) |
499 | 2241 { |
611 | 2242 ngx_int_t rc; |
4641
045bb3ef3ffc
Fixed core variables dynamic access after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
2243 ngx_http_variable_t *cv, *v; |
501 | 2244 ngx_http_core_main_conf_t *cmcf; |
499 | 2245 |
509 | 2246 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); |
2247 | |
611 | 2248 cmcf->variables_keys = ngx_pcalloc(cf->temp_pool, |
2249 sizeof(ngx_hash_keys_arrays_t)); | |
2250 if (cmcf->variables_keys == NULL) { | |
2251 return NGX_ERROR; | |
2252 } | |
2253 | |
2254 cmcf->variables_keys->pool = cf->pool; | |
2255 cmcf->variables_keys->temp_pool = cf->pool; | |
2256 | |
2257 if (ngx_hash_keys_array_init(cmcf->variables_keys, NGX_HASH_SMALL) | |
2258 != NGX_OK) | |
509 | 2259 { |
499 | 2260 return NGX_ERROR; |
2261 } | |
2262 | |
4641
045bb3ef3ffc
Fixed core variables dynamic access after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
2263 for (cv = ngx_http_core_variables; cv->name.len; cv++) { |
045bb3ef3ffc
Fixed core variables dynamic access after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
2264 v = ngx_palloc(cf->pool, sizeof(ngx_http_variable_t)); |
045bb3ef3ffc
Fixed core variables dynamic access after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
2265 if (v == NULL) { |
045bb3ef3ffc
Fixed core variables dynamic access after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
2266 return NGX_ERROR; |
045bb3ef3ffc
Fixed core variables dynamic access after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
2267 } |
045bb3ef3ffc
Fixed core variables dynamic access after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
2268 |
045bb3ef3ffc
Fixed core variables dynamic access after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
2269 *v = *cv; |
045bb3ef3ffc
Fixed core variables dynamic access after reconfiguration.
Maxim Dounin <mdounin@mdounin.ru>
parents:
4572
diff
changeset
|
2270 |
611 | 2271 rc = ngx_hash_add_key(cmcf->variables_keys, &v->name, v, |
2272 NGX_HASH_READONLY_KEY); | |
2273 | |
2274 if (rc == NGX_OK) { | |
2275 continue; | |
499 | 2276 } |
2277 | |
611 | 2278 if (rc == NGX_BUSY) { |
2279 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | |
2280 "conflicting variable name \"%V\"", &v->name); | |
2281 } | |
2282 | |
2283 return NGX_ERROR; | |
499 | 2284 } |
2285 | |
2286 return NGX_OK; | |
2287 } | |
509 | 2288 |
2289 | |
2290 ngx_int_t | |
2291 ngx_http_variables_init_vars(ngx_conf_t *cf) | |
2292 { | |
2293 ngx_uint_t i, n; | |
611 | 2294 ngx_hash_key_t *key; |
2295 ngx_hash_init_t hash; | |
509 | 2296 ngx_http_variable_t *v, *av; |
2297 ngx_http_core_main_conf_t *cmcf; | |
2298 | |
2299 /* set the handlers for the indexed http variables */ | |
2300 | |
2301 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module); | |
2302 | |
2303 v = cmcf->variables.elts; | |
611 | 2304 key = cmcf->variables_keys->keys.elts; |
509 | 2305 |
2306 for (i = 0; i < cmcf->variables.nelts; i++) { | |
2307 | |
611 | 2308 for (n = 0; n < cmcf->variables_keys->keys.nelts; n++) { |
509 | 2309 |
1191
0eb2dc4fdea8
fix segfault introduced in r1190
Igor Sysoev <igor@sysoev.ru>
parents:
1173
diff
changeset
|
2310 av = key[n].value; |
0eb2dc4fdea8
fix segfault introduced in r1190
Igor Sysoev <igor@sysoev.ru>
parents:
1173
diff
changeset
|
2311 |
0eb2dc4fdea8
fix segfault introduced in r1190
Igor Sysoev <igor@sysoev.ru>
parents:
1173
diff
changeset
|
2312 if (av->get_handler |
0eb2dc4fdea8
fix segfault introduced in r1190
Igor Sysoev <igor@sysoev.ru>
parents:
1173
diff
changeset
|
2313 && v[i].name.len == key[n].key.len |
611 | 2314 && ngx_strncmp(v[i].name.data, key[n].key.data, v[i].name.len) |
509 | 2315 == 0) |
2316 { | |
637 | 2317 v[i].get_handler = av->get_handler; |
611 | 2318 v[i].data = av->data; |
527 | 2319 |
611 | 2320 av->flags |= NGX_HTTP_VAR_INDEXED; |
2321 v[i].flags = av->flags; | |
509 | 2322 |
611 | 2323 av->index = i; |
533 | 2324 |
509 | 2325 goto next; |
2326 } | |
2327 } | |
2328 | |
2329 if (ngx_strncmp(v[i].name.data, "http_", 5) == 0) { | |
637 | 2330 v[i].get_handler = ngx_http_variable_unknown_header_in; |
577 | 2331 v[i].data = (uintptr_t) &v[i].name; |
2332 | |
2333 continue; | |
2334 } | |
2335 | |
2336 if (ngx_strncmp(v[i].name.data, "sent_http_", 10) == 0) { | |
637 | 2337 v[i].get_handler = ngx_http_variable_unknown_header_out; |
509 | 2338 v[i].data = (uintptr_t) &v[i].name; |
2339 | |
2340 continue; | |
2341 } | |
2342 | |
1162 | 2343 if (ngx_strncmp(v[i].name.data, "upstream_http_", 14) == 0) { |
2344 v[i].get_handler = ngx_http_upstream_header_variable; | |
2345 v[i].data = (uintptr_t) &v[i].name; | |
1565 | 2346 v[i].flags = NGX_HTTP_VAR_NOCACHEABLE; |
1162 | 2347 |
2348 continue; | |
2349 } | |
2350 | |
2307 | 2351 if (ngx_strncmp(v[i].name.data, "cookie_", 7) == 0) { |
2352 v[i].get_handler = ngx_http_variable_cookie; | |
2353 v[i].data = (uintptr_t) &v[i].name; | |
2354 | |
2355 continue; | |
2356 } | |
2357 | |
2137 | 2358 if (ngx_strncmp(v[i].name.data, "arg_", 4) == 0) { |
2359 v[i].get_handler = ngx_http_variable_argument; | |
2360 v[i].data = (uintptr_t) &v[i].name; | |
3499
b4a14d50388b
make $arg_ variables non-cacheable
Igor Sysoev <igor@sysoev.ru>
parents:
3463
diff
changeset
|
2361 v[i].flags = NGX_HTTP_VAR_NOCACHEABLE; |
2137 | 2362 |
2363 continue; | |
2364 } | |
2365 | |
509 | 2366 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |
2367 "unknown \"%V\" variable", &v[i].name); | |
2368 | |
2369 return NGX_ERROR; | |
2370 | |
2371 next: | |
2372 continue; | |
2373 } | |
2374 | |
2375 | |
611 | 2376 for (n = 0; n < cmcf->variables_keys->keys.nelts; n++) { |
2377 av = key[n].value; | |
2378 | |
2379 if (av->flags & NGX_HTTP_VAR_NOHASH) { | |
2380 key[n].key.data = NULL; | |
583 | 2381 } |
2382 } | |
2383 | |
2384 | |
611 | 2385 hash.hash = &cmcf->variables_hash; |
2386 hash.key = ngx_hash_key; | |
2387 hash.max_size = cmcf->variables_hash_max_size; | |
2388 hash.bucket_size = cmcf->variables_hash_bucket_size; | |
2389 hash.name = "variables_hash"; | |
2390 hash.pool = cf->pool; | |
2391 hash.temp_pool = NULL; | |
509 | 2392 |
611 | 2393 if (ngx_hash_init(&hash, cmcf->variables_keys->keys.elts, |
2394 cmcf->variables_keys->keys.nelts) | |
581 | 2395 != NGX_OK) |
509 | 2396 { |
2397 return NGX_ERROR; | |
2398 } | |
2399 | |
611 | 2400 cmcf->variables_keys = NULL; |
509 | 2401 |
2402 return NGX_OK; | |
2403 } |