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