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