annotate src/http/ngx_http_variables.c @ 412:b246022ef454 NGINX_0_7_18

nginx 0.7.18 *) Change: the "underscores_in_headers" directive; now nginx does not allows underscores in a client request header line names. *) Feature: the ngx_http_secure_link_module. *) Feature: the "real_ip_header" directive supports any header. *) Feature: the "log_subrequest" directive. *) Feature: the $realpath_root variable. *) Feature: the "http_502" and "http_504" parameters of the "proxy_next_upstream" directive. *) Bugfix: the "http_503" parameter of the "proxy_next_upstream" or "fastcgi_next_upstream" directives did not work. *) Bugfix: nginx might send a "Transfer-Encoding: chunked" heaer line for HEAD requests. *) Bugfix: now accept threshold depends on worker_connections.
author Igor Sysoev <http://sysoev.ru>
date Mon, 13 Oct 2008 00:00:00 +0400
parents a8e3f1441eec
children ad0a34a8efa6
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
2 /*
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
3 * Copyright (C) Igor Sysoev
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
4 */
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
5
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
6
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
7 #include <ngx_config.h>
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
8 #include <ngx_core.h>
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
9 #include <ngx_http.h>
322
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
10 #include <nginx.h>
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
11
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
12
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
13 static ngx_int_t ngx_http_variable_request(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
14 ngx_http_variable_value_t *v, uintptr_t data);
324
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
15 static void ngx_http_variable_request_set(ngx_http_request_t *r,
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
16 ngx_http_variable_value_t *v, uintptr_t data);
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
17 static void ngx_http_variable_request_set_size(ngx_http_request_t *r,
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
18 ngx_http_variable_value_t *v, uintptr_t data);
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
19 static ngx_int_t ngx_http_variable_header(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
20 ngx_http_variable_value_t *v, uintptr_t data);
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
21 static ngx_int_t ngx_http_variable_headers(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
22 ngx_http_variable_value_t *v, uintptr_t data);
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
23
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
24 static ngx_int_t ngx_http_variable_unknown_header_in(ngx_http_request_t *r,
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
25 ngx_http_variable_value_t *v, uintptr_t data);
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
26 static ngx_int_t ngx_http_variable_unknown_header_out(ngx_http_request_t *r,
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
27 ngx_http_variable_value_t *v, uintptr_t data);
392
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
28 static ngx_int_t ngx_http_variable_argument(ngx_http_request_t *r,
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
29 ngx_http_variable_value_t *v, uintptr_t data);
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
30
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
31 static ngx_int_t ngx_http_variable_host(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
32 ngx_http_variable_value_t *v, uintptr_t data);
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
33 static ngx_int_t ngx_http_variable_binary_remote_addr(ngx_http_request_t *r,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
34 ngx_http_variable_value_t *v, uintptr_t data);
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
35 static ngx_int_t ngx_http_variable_remote_addr(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
36 ngx_http_variable_value_t *v, uintptr_t data);
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
37 static ngx_int_t ngx_http_variable_remote_port(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
38 ngx_http_variable_value_t *v, uintptr_t data);
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
39 static ngx_int_t ngx_http_variable_server_addr(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
40 ngx_http_variable_value_t *v, uintptr_t data);
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
41 static ngx_int_t ngx_http_variable_server_port(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
42 ngx_http_variable_value_t *v, uintptr_t data);
238
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
43 static ngx_int_t ngx_http_variable_scheme(ngx_http_request_t *r,
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
44 ngx_http_variable_value_t *v, uintptr_t data);
324
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
45 static ngx_int_t ngx_http_variable_is_args(ngx_http_request_t *r,
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
46 ngx_http_variable_value_t *v, uintptr_t data);
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
47 static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
48 ngx_http_variable_value_t *v, uintptr_t data);
412
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
49 static ngx_int_t ngx_http_variable_realpath_root(ngx_http_request_t *r,
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
50 ngx_http_variable_value_t *v, uintptr_t data);
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
51 static ngx_int_t ngx_http_variable_request_filename(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
52 ngx_http_variable_value_t *v, uintptr_t data);
362
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
53 static ngx_int_t ngx_http_variable_server_name(ngx_http_request_t *r,
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
54 ngx_http_variable_value_t *v, uintptr_t data);
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
55 static ngx_int_t ngx_http_variable_request_method(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
56 ngx_http_variable_value_t *v, uintptr_t data);
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
57 static ngx_int_t ngx_http_variable_remote_user(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
58 ngx_http_variable_value_t *v, uintptr_t data);
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
59 static ngx_int_t ngx_http_variable_body_bytes_sent(ngx_http_request_t *r,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
60 ngx_http_variable_value_t *v, uintptr_t data);
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
61 static ngx_int_t ngx_http_variable_request_completion(ngx_http_request_t *r,
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
62 ngx_http_variable_value_t *v, uintptr_t data);
244
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
63 static ngx_int_t ngx_http_variable_request_body_file(ngx_http_request_t *r,
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
64 ngx_http_variable_value_t *v, uintptr_t data);
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
65
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
66 static ngx_int_t ngx_http_variable_sent_content_type(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
67 ngx_http_variable_value_t *v, uintptr_t data);
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
68 static ngx_int_t ngx_http_variable_sent_content_length(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
69 ngx_http_variable_value_t *v, uintptr_t data);
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
70 static ngx_int_t ngx_http_variable_sent_last_modified(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
71 ngx_http_variable_value_t *v, uintptr_t data);
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
72 static ngx_int_t ngx_http_variable_sent_connection(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
73 ngx_http_variable_value_t *v, uintptr_t data);
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
74 static ngx_int_t ngx_http_variable_sent_keep_alive(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
75 ngx_http_variable_value_t *v, uintptr_t data);
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
76 static ngx_int_t ngx_http_variable_sent_transfer_encoding(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
77 ngx_http_variable_value_t *v, uintptr_t data);
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
78
322
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
79 static ngx_int_t ngx_http_variable_nginx_version(ngx_http_request_t *r,
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
80 ngx_http_variable_value_t *v, uintptr_t data);
376
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
81 static ngx_int_t ngx_http_variable_hostname(ngx_http_request_t *r,
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
82 ngx_http_variable_value_t *v, uintptr_t data);
410
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
83 static ngx_int_t ngx_http_variable_pid(ngx_http_request_t *r,
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
84 ngx_http_variable_value_t *v, uintptr_t data);
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
85
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
86 /*
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
87 * TODO:
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
88 * Apache CGI: AUTH_TYPE, PATH_INFO (null), PATH_TRANSLATED
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
89 * REMOTE_HOST (null), REMOTE_IDENT (null),
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
90 * SERVER_SOFTWARE
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
91 *
120
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
92 * Apache SSI: DOCUMENT_NAME, LAST_MODIFIED, USER_NAME (file owner)
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
93 */
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
94
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
95 /*
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
96 * the $http_host, $http_user_agent, $http_referer, $http_via,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
97 * and $http_x_forwarded_for variables may be handled by generic
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
98 * ngx_http_variable_unknown_header_in(), but for perfomance reasons
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
99 * they are handled using dedicated entries
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
100 */
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
101
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
102 static ngx_http_variable_t ngx_http_core_variables[] = {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
103
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
104 { ngx_string("http_host"), NULL, ngx_http_variable_header,
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
105 offsetof(ngx_http_request_t, headers_in.host), 0, 0 },
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
106
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
107 { ngx_string("http_user_agent"), NULL, ngx_http_variable_header,
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
108 offsetof(ngx_http_request_t, headers_in.user_agent), 0, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
109
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
110 { ngx_string("http_referer"), NULL, ngx_http_variable_header,
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
111 offsetof(ngx_http_request_t, headers_in.referer), 0, 0 },
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
112
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
113 #if (NGX_HTTP_GZIP)
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
114 { ngx_string("http_via"), NULL, ngx_http_variable_header,
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
115 offsetof(ngx_http_request_t, headers_in.via), 0, 0 },
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
116 #endif
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
117
286
5bef04fc3fd5 nginx 0.5.13
Igor Sysoev <http://sysoev.ru>
parents: 272
diff changeset
118 #if (NGX_HTTP_PROXY || NGX_HTTP_REALIP)
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
119 { ngx_string("http_x_forwarded_for"), NULL, ngx_http_variable_header,
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
120 offsetof(ngx_http_request_t, headers_in.x_forwarded_for), 0, 0 },
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
121 #endif
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
122
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
123 { ngx_string("http_cookie"), NULL, ngx_http_variable_headers,
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
124 offsetof(ngx_http_request_t, headers_in.cookies), 0, 0 },
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
125
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
126 { ngx_string("content_length"), NULL, ngx_http_variable_header,
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
127 offsetof(ngx_http_request_t, headers_in.content_length), 0, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
128
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
129 { ngx_string("content_type"), NULL, ngx_http_variable_header,
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
130 offsetof(ngx_http_request_t, headers_in.content_type), 0, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
131
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
132 { ngx_string("host"), NULL, ngx_http_variable_host, 0, 0, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
133
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
134 { ngx_string("binary_remote_addr"), NULL,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
135 ngx_http_variable_binary_remote_addr, 0, 0, 0 },
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
136
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
137 { ngx_string("remote_addr"), NULL, ngx_http_variable_remote_addr, 0, 0, 0 },
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
138
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
139 { ngx_string("remote_port"), NULL, ngx_http_variable_remote_port, 0, 0, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
140
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
141 { ngx_string("server_addr"), NULL, ngx_http_variable_server_addr, 0, 0, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
142
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
143 { ngx_string("server_port"), NULL, ngx_http_variable_server_port, 0, 0, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
144
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
145 { ngx_string("server_protocol"), NULL, ngx_http_variable_request,
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
146 offsetof(ngx_http_request_t, http_protocol), 0, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
147
238
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
148 { ngx_string("scheme"), NULL, ngx_http_variable_scheme, 0, 0, 0 },
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
149
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
150 { ngx_string("request_uri"), NULL, ngx_http_variable_request,
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
151 offsetof(ngx_http_request_t, unparsed_uri), 0, 0 },
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
152
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
153 { ngx_string("uri"), NULL, ngx_http_variable_request,
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
154 offsetof(ngx_http_request_t, uri),
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
155 NGX_HTTP_VAR_NOCACHEABLE, 0 },
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
156
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
157 { ngx_string("document_uri"), NULL, ngx_http_variable_request,
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
158 offsetof(ngx_http_request_t, uri),
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
159 NGX_HTTP_VAR_NOCACHEABLE, 0 },
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
160
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
161 { ngx_string("request"), NULL, ngx_http_variable_request,
118
644a7935144b nginx 0.3.6
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
162 offsetof(ngx_http_request_t, request_line), 0, 0 },
644a7935144b nginx 0.3.6
Igor Sysoev <http://sysoev.ru>
parents: 110
diff changeset
163
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
164 { ngx_string("document_root"), NULL,
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
165 ngx_http_variable_document_root, 0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
166
412
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
167 { ngx_string("realpath_root"), NULL,
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
168 ngx_http_variable_realpath_root, 0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
169
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
170 { ngx_string("query_string"), NULL, ngx_http_variable_request,
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
171 offsetof(ngx_http_request_t, args),
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
172 NGX_HTTP_VAR_NOCACHEABLE, 0 },
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
173
324
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
174 { ngx_string("args"),
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
175 ngx_http_variable_request_set,
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
176 ngx_http_variable_request,
138
8e6d4d96ec4c nginx 0.3.16
Igor Sysoev <http://sysoev.ru>
parents: 132
diff changeset
177 offsetof(ngx_http_request_t, args),
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
178 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
324
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
179
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
180 { ngx_string("is_args"), NULL, ngx_http_variable_is_args,
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
181 0, NGX_HTTP_VAR_NOCACHEABLE, 0 },
138
8e6d4d96ec4c nginx 0.3.16
Igor Sysoev <http://sysoev.ru>
parents: 132
diff changeset
182
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
183 { ngx_string("request_filename"), NULL,
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
184 ngx_http_variable_request_filename, 0,
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
185 NGX_HTTP_VAR_NOCACHEABLE, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
186
362
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
187 { ngx_string("server_name"), NULL, ngx_http_variable_server_name, 0, 0, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
188
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
189 { ngx_string("request_method"), NULL,
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
190 ngx_http_variable_request_method, 0, 0, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
191
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
192 { ngx_string("remote_user"), NULL, ngx_http_variable_remote_user, 0, 0, 0 },
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
193
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
194 { ngx_string("body_bytes_sent"), NULL, ngx_http_variable_body_bytes_sent,
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
195 0, 0, 0 },
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
196
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
197 { ngx_string("request_completion"), NULL,
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
198 ngx_http_variable_request_completion,
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
199 0, 0, 0 },
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
200
244
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
201 { ngx_string("request_body_file"), NULL,
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
202 ngx_http_variable_request_body_file,
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
203 0, 0, 0 },
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
204
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
205 { ngx_string("sent_http_content_type"), NULL,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
206 ngx_http_variable_sent_content_type, 0, 0, 0 },
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
207
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
208 { ngx_string("sent_http_content_length"), NULL,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
209 ngx_http_variable_sent_content_length, 0, 0, 0 },
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
210
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
211 { ngx_string("sent_http_last_modified"), NULL,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
212 ngx_http_variable_sent_last_modified, 0, 0, 0 },
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
213
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
214 { ngx_string("sent_http_connection"), NULL,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
215 ngx_http_variable_sent_connection, 0, 0, 0 },
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
216
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
217 { ngx_string("sent_http_keep_alive"), NULL,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
218 ngx_http_variable_sent_keep_alive, 0, 0, 0 },
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
219
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
220 { ngx_string("sent_http_transfer_encoding"), NULL,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
221 ngx_http_variable_sent_transfer_encoding, 0, 0, 0 },
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
222
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
223 { ngx_string("sent_http_cache_control"), NULL, ngx_http_variable_headers,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
224 offsetof(ngx_http_request_t, headers_out.cache_control), 0, 0 },
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
225
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
226 { ngx_string("limit_rate"), ngx_http_variable_request_set_size,
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
227 ngx_http_variable_request,
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
228 offsetof(ngx_http_request_t, limit_rate),
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
229 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 },
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
230
322
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
231 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version,
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
232 0, 0, 0 },
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
233
376
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
234 { ngx_string("hostname"), NULL, ngx_http_variable_hostname,
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
235 0, 0, 0 },
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
236
410
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
237 { ngx_string("pid"), NULL, ngx_http_variable_pid,
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
238 0, 0, 0 },
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
239
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
240 { ngx_null_string, NULL, NULL, 0, 0, 0 }
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
241 };
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
242
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
243
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
244 ngx_http_variable_value_t ngx_http_variable_null_value =
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
245 ngx_http_variable("");
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
246 ngx_http_variable_value_t ngx_http_variable_true_value =
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
247 ngx_http_variable("1");
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
248
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
249
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
250 ngx_http_variable_t *
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
251 ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name, ngx_uint_t flags)
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
252 {
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
253 ngx_int_t rc;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
254 ngx_uint_t i;
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
255 ngx_hash_key_t *key;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
256 ngx_http_variable_t *v;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
257 ngx_http_core_main_conf_t *cmcf;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
258
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
259 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
260
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
261 key = cmcf->variables_keys->keys.elts;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
262 for (i = 0; i < cmcf->variables_keys->keys.nelts; i++) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
263 if (name->len != key[i].key.len
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
264 || ngx_strncasecmp(name->data, key[i].key.data, name->len) != 0)
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
265 {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
266 continue;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
267 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
268
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
269 v = key[i].value;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
270
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
271 if (!(v->flags & NGX_HTTP_VAR_CHANGEABLE)) {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
272 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
273 "the duplicate \"%V\" variable", name);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
274 return NULL;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
275 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
276
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
277 return v;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
278 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
279
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
280 v = ngx_palloc(cf->pool, sizeof(ngx_http_variable_t));
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
281 if (v == NULL) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
282 return NULL;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
283 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
284
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
285 v->name.len = name->len;
382
984bb0b1399b nginx 0.7.3
Igor Sysoev <http://sysoev.ru>
parents: 376
diff changeset
286 v->name.data = ngx_pnalloc(cf->pool, name->len);
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
287 if (v->name.data == NULL) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
288 return NULL;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
289 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
290
392
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
291 ngx_strlow(v->name.data, name->data, name->len);
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
292
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
293 v->set_handler = NULL;
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
294 v->get_handler = NULL;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
295 v->data = 0;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
296 v->flags = flags;
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
297 v->index = 0;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
298
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
299 rc = ngx_hash_add_key(cmcf->variables_keys, &v->name, v, 0);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
300
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
301 if (rc == NGX_ERROR) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
302 return NULL;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
303 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
304
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
305 if (rc == NGX_BUSY) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
306 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
307 "conflicting variable name \"%V\"", name);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
308 return NULL;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
309 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
310
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
311 return v;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
312 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
313
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
314
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
315 ngx_int_t
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
316 ngx_http_get_variable_index(ngx_conf_t *cf, ngx_str_t *name)
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
317 {
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
318 ngx_uint_t i;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
319 ngx_http_variable_t *v;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
320 ngx_http_core_main_conf_t *cmcf;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
321
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
322 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
323
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
324 v = cmcf->variables.elts;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
325
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
326 if (v == NULL) {
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
327 if (ngx_array_init(&cmcf->variables, cf->pool, 4,
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
328 sizeof(ngx_http_variable_t)) == NGX_ERROR)
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
329 {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
330 return NGX_ERROR;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
331 }
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
332
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
333 } else {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
334 for (i = 0; i < cmcf->variables.nelts; i++) {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
335 if (name->len != v[i].name.len
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
336 || ngx_strncasecmp(name->data, v[i].name.data, name->len) != 0)
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
337 {
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
338 continue;
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
339 }
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
340
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
341 return i;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
342 }
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
343 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
344
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
345 v = ngx_array_push(&cmcf->variables);
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
346 if (v == NULL) {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
347 return NGX_ERROR;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
348 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
349
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
350 v->name.len = name->len;
382
984bb0b1399b nginx 0.7.3
Igor Sysoev <http://sysoev.ru>
parents: 376
diff changeset
351 v->name.data = ngx_pnalloc(cf->pool, name->len);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
352 if (v->name.data == NULL) {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
353 return NGX_ERROR;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
354 }
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
355
392
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
356 ngx_strlow(v->name.data, name->data, name->len);
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
357
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
358 v->set_handler = NULL;
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
359 v->get_handler = NULL;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
360 v->data = 0;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
361 v->flags = 0;
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
362 v->index = cmcf->variables.nelts - 1;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
363
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
364 return cmcf->variables.nelts - 1;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
365 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
366
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
367
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
368 ngx_http_variable_value_t *
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
369 ngx_http_get_indexed_variable(ngx_http_request_t *r, ngx_uint_t index)
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
370 {
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
371 ngx_http_variable_t *v;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
372 ngx_http_core_main_conf_t *cmcf;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
373
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
374 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
375
102
f63280c59dd5 nginx 0.2.5
Igor Sysoev <http://sysoev.ru>
parents: 88
diff changeset
376 if (cmcf->variables.nelts <= index) {
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
377 ngx_log_error(NGX_LOG_ALERT, r->connection->log, 0,
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
378 "unknown variable index: %d", index);
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
379 return NULL;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
380 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
381
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
382 if (r->variables[index].not_found || r->variables[index].valid) {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
383 return &r->variables[index];
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
384 }
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
385
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
386 v = cmcf->variables.elts;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
387
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
388 if (v[index].get_handler(r, &r->variables[index], v[index].data)
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
389 == NGX_OK)
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
390 {
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
391 if (v[index].flags & NGX_HTTP_VAR_NOCACHEABLE) {
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
392 r->variables[index].no_cacheable = 1;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
393 }
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
394
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
395 return &r->variables[index];
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
396 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
397
206
3866d57d9cfd nginx 0.3.50
Igor Sysoev <http://sysoev.ru>
parents: 196
diff changeset
398 r->variables[index].valid = 0;
3866d57d9cfd nginx 0.3.50
Igor Sysoev <http://sysoev.ru>
parents: 196
diff changeset
399 r->variables[index].not_found = 1;
3866d57d9cfd nginx 0.3.50
Igor Sysoev <http://sysoev.ru>
parents: 196
diff changeset
400
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
401 return NULL;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
402 }
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
403
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
404
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
405 ngx_http_variable_value_t *
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
406 ngx_http_get_flushed_variable(ngx_http_request_t *r, ngx_uint_t index)
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
407 {
294
27d9d1f26b38 nginx 0.5.17
Igor Sysoev <http://sysoev.ru>
parents: 286
diff changeset
408 ngx_http_variable_value_t *v;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
409
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
410 v = &r->variables[index];
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
411
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
412 if (v->valid) {
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
413 if (!v->no_cacheable) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
414 return v;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
415 }
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
416
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
417 v->valid = 0;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
418 v->not_found = 0;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
419 }
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
420
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
421 return ngx_http_get_indexed_variable(r, index);
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
422 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
423
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
424
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
425 ngx_http_variable_value_t *
184
71ff1e2b484a nginx 0.3.39
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
426 ngx_http_get_variable(ngx_http_request_t *r, ngx_str_t *name, ngx_uint_t key,
71ff1e2b484a nginx 0.3.39
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
427 ngx_uint_t nowarn)
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
428 {
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
429 ngx_http_variable_t *v;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
430 ngx_http_variable_value_t *vv;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
431 ngx_http_core_main_conf_t *cmcf;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
432
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
433 cmcf = ngx_http_get_module_main_conf(r, ngx_http_core_module);
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
434
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
435 v = ngx_hash_find(&cmcf->variables_hash, key, name->data, name->len);
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
436
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
437 if (v) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
438 if (v->flags & NGX_HTTP_VAR_INDEXED) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
439 return ngx_http_get_indexed_variable(r, v->index);
68
056fd0e5a5a6 nginx 0.1.34
Igor Sysoev <http://sysoev.ru>
parents: 64
diff changeset
440
056fd0e5a5a6 nginx 0.1.34
Igor Sysoev <http://sysoev.ru>
parents: 64
diff changeset
441 } else {
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
442
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
443 vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t));
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
444
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
445 if (vv && v->get_handler(r, vv, v->data) == NGX_OK) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
446 return vv;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
447 }
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
448
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
449 return NULL;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
450 }
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
451 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
452
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
453 vv = ngx_palloc(r->pool, sizeof(ngx_http_variable_value_t));
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
454 if (vv == NULL) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
455 return NULL;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
456 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
457
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
458 if (ngx_strncmp(name->data, "http_", 5) == 0) {
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
459
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
460 if (ngx_http_variable_unknown_header_in(r, vv, (uintptr_t) name)
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
461 == NGX_OK)
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
462 {
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
463 return vv;
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
464 }
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
465
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
466 return NULL;
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
467 }
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
468
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
469 if (ngx_strncmp(name->data, "sent_http_", 10) == 0) {
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
470
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
471 if (ngx_http_variable_unknown_header_out(r, vv, (uintptr_t) name)
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
472 == NGX_OK)
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
473 {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
474 return vv;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
475 }
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
476
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
477 return NULL;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
478 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
479
296
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
480 if (ngx_strncmp(name->data, "upstream_http_", 10) == 0) {
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
481
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
482 if (ngx_http_upstream_header_variable(r, vv, (uintptr_t) name)
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
483 == NGX_OK)
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
484 {
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
485 return vv;
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
486 }
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
487
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
488 return NULL;
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
489 }
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
490
392
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
491 if (ngx_strncmp(name->data, "arg_", 4) == 0) {
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
492
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
493 if (ngx_http_variable_argument(r, vv, (uintptr_t) name) == NGX_OK) {
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
494 return vv;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
495 }
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
496
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
497 return NULL;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
498 }
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
499
184
71ff1e2b484a nginx 0.3.39
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
500 vv->not_found = 1;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
501
184
71ff1e2b484a nginx 0.3.39
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
502 if (nowarn == 0) {
71ff1e2b484a nginx 0.3.39
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
503 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
71ff1e2b484a nginx 0.3.39
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
504 "unknown \"%V\" variable", name);
71ff1e2b484a nginx 0.3.39
Igor Sysoev <http://sysoev.ru>
parents: 178
diff changeset
505 }
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
506
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
507 return vv;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
508 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
509
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
510
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
511 static ngx_int_t
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
512 ngx_http_variable_request(ngx_http_request_t *r, ngx_http_variable_value_t *v,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
513 uintptr_t data)
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
514 {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
515 ngx_str_t *s;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
516
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
517 s = (ngx_str_t *) ((char *) r + data);
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
518
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
519 if (s->data) {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
520 v->len = s->len;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
521 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
522 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
523 v->not_found = 0;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
524 v->data = s->data;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
525
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
526 } else {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
527 v->not_found = 1;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
528 }
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
529
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
530 return NGX_OK;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
531 }
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
532
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
533
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
534 static void
324
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
535 ngx_http_variable_request_set(ngx_http_request_t *r,
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
536 ngx_http_variable_value_t *v, uintptr_t data)
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
537 {
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
538 ngx_str_t *s;
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
539
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
540 s = (ngx_str_t *) ((char *) r + data);
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
541
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
542 s->len = v->len;
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
543 s->data = v->data;
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
544 }
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
545
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
546
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
547 static void
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
548 ngx_http_variable_request_set_size(ngx_http_request_t *r,
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
549 ngx_http_variable_value_t *v, uintptr_t data)
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
550 {
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
551 ssize_t s, *sp;
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
552 ngx_str_t val;
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
553
320
95183808f549 nginx 0.6.4
Igor Sysoev <http://sysoev.ru>
parents: 300
diff changeset
554 val.len = v->len;
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
555 val.data = v->data;
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
556
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
557 s = ngx_parse_size(&val);
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
558
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
559 if (s == NGX_ERROR) {
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
560 ngx_log_error(NGX_LOG_ERR, r->connection->log, 0,
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
561 "invalid size \"%V\"", &val);
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
562 return;
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
563 }
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
564
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
565 sp = (ssize_t *) ((char *) r + data);
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
566
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
567 *sp = s;
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
568
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
569 return;
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
570 }
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
571
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
572
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
573 static ngx_int_t
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
574 ngx_http_variable_header(ngx_http_request_t *r, ngx_http_variable_value_t *v,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
575 uintptr_t data)
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
576 {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
577 ngx_table_elt_t *h;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
578
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
579 h = *(ngx_table_elt_t **) ((char *) r + data);
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
580
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
581 if (h) {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
582 v->len = h->value.len;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
583 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
584 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
585 v->not_found = 0;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
586 v->data = h->value.data;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
587
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
588 } else {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
589 v->not_found = 1;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
590 }
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
591
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
592 return NGX_OK;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
593 }
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
594
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
595
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
596 static ngx_int_t
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
597 ngx_http_variable_headers(ngx_http_request_t *r, ngx_http_variable_value_t *v,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
598 uintptr_t data)
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
599 {
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 206
diff changeset
600 ssize_t len;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
601 u_char *p;
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 206
diff changeset
602 ngx_uint_t i, n;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
603 ngx_array_t *a;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
604 ngx_table_elt_t **h;
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
605
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
606 a = (ngx_array_t *) ((char *) r + data);
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
607
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 206
diff changeset
608 n = a->nelts;
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 206
diff changeset
609
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 206
diff changeset
610 if (n == 0) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
611 v->not_found = 1;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
612 return NGX_OK;
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
613 }
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
614
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
615 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
616 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
617 v->not_found = 0;
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
618
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
619 h = a->elts;
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
620
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 206
diff changeset
621 if (n == 1) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
622 v->len = (*h)->value.len;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
623 v->data = (*h)->value.data;
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
624
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
625 return NGX_OK;
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
626 }
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
627
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 206
diff changeset
628 len = - (ssize_t) (sizeof("; ") - 1);
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
629
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 206
diff changeset
630 for (i = 0; i < n; i++) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
631 len += h[i]->value.len + sizeof("; ") - 1;
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
632 }
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
633
382
984bb0b1399b nginx 0.7.3
Igor Sysoev <http://sysoev.ru>
parents: 376
diff changeset
634 p = ngx_pnalloc(r->pool, len);
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
635 if (p == NULL) {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
636 return NGX_ERROR;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
637 }
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
638
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
639 v->len = len;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
640 v->data = p;
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
641
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
642 for (i = 0; /* void */ ; i++) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
643 p = ngx_copy(p, h[i]->value.data, h[i]->value.len);
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
644
216
fa32d59d9a15 nginx 0.3.55
Igor Sysoev <http://sysoev.ru>
parents: 206
diff changeset
645 if (i == n - 1) {
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
646 break;
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
647 }
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
648
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
649 *p++ = ';'; *p++ = ' ';
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
650 }
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
651
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
652 return NGX_OK;
64
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
653 }
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
654
5db440287648 nginx 0.1.32
Igor Sysoev <http://sysoev.ru>
parents: 58
diff changeset
655
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
656 static ngx_int_t
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
657 ngx_http_variable_unknown_header_in(ngx_http_request_t *r,
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
658 ngx_http_variable_value_t *v, uintptr_t data)
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
659 {
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
660 return ngx_http_variable_unknown_header(v, (ngx_str_t *) data,
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
661 &r->headers_in.headers.part,
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
662 sizeof("http_") - 1);
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
663 }
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
664
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
665
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
666 static ngx_int_t
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
667 ngx_http_variable_unknown_header_out(ngx_http_request_t *r,
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
668 ngx_http_variable_value_t *v, uintptr_t data)
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
669 {
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
670 return ngx_http_variable_unknown_header(v, (ngx_str_t *) data,
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
671 &r->headers_out.headers.part,
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
672 sizeof("sent_http_") - 1);
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
673 }
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
674
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
675
296
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
676 ngx_int_t
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
677 ngx_http_variable_unknown_header(ngx_http_variable_value_t *v, ngx_str_t *var,
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
678 ngx_list_part_t *part, size_t prefix)
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
679 {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
680 u_char ch;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
681 ngx_uint_t i, n;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
682 ngx_table_elt_t *header;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
683
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
684 header = part->elts;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
685
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
686 for (i = 0; /* void */ ; i++) {
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
687
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
688 if (i >= part->nelts) {
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
689 if (part->next == NULL) {
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
690 break;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
691 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
692
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
693 part = part->next;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
694 header = part->elts;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
695 i = 0;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
696 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
697
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
698 for (n = 0; n + prefix < var->len && n < header[i].key.len; n++) {
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
699 ch = header[i].key.data[n];
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
700
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
701 if (ch >= 'A' && ch <= 'Z') {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
702 ch |= 0x20;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
703
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
704 } else if (ch == '-') {
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
705 ch = '_';
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
706 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
707
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
708 if (var->data[n + prefix] != ch) {
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
709 break;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
710 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
711 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
712
242
ff906029dd40 nginx 0.4.6
Igor Sysoev <http://sysoev.ru>
parents: 238
diff changeset
713 if (n + prefix == var->len && n == header[i].key.len) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
714 v->len = header[i].value.len;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
715 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
716 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
717 v->not_found = 0;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
718 v->data = header[i].value.data;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
719
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
720 return NGX_OK;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
721 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
722 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
723
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
724 v->not_found = 1;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
725
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
726 return NGX_OK;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
727 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
728
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
729
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
730 static ngx_int_t
392
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
731 ngx_http_variable_argument(ngx_http_request_t *r, ngx_http_variable_value_t *v,
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
732 uintptr_t data)
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
733 {
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
734 ngx_str_t *name = (ngx_str_t *) data;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
735
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
736 u_char *p, *arg;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
737 size_t len;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
738
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
739 if (r->args.len == 0) {
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
740 v->not_found = 1;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
741 return NGX_OK;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
742 }
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
743
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
744 len = name->len - 1 - (sizeof("arg_") - 1);
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
745 arg = name->data + sizeof("arg_") - 1;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
746
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
747 for (p = r->args.data; *p && *p != ' '; p++) {
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
748
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
749 /*
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
750 * although r->args.data is not null-terminated by itself,
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
751 * however, there is null in the end of request line
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
752 */
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
753
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
754 p = ngx_strcasestrn(p, (char *) arg, len);
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
755
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
756 if (p == NULL) {
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
757 v->not_found = 1;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
758 return NGX_OK;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
759 }
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
760
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
761 if ((p == r->args.data || *(p - 1) == '&') && *(p + len + 1) == '=') {
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
762
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
763 v->data = p + len + 2;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
764
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
765 p = (u_char *) ngx_strchr(p, '&');
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
766
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
767 if (p == NULL) {
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
768 p = r->args.data + r->args.len;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
769 }
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
770
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
771 v->len = p - v->data;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
772 v->valid = 1;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
773 v->no_cacheable = 0;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
774 v->not_found = 0;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
775
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
776 return NGX_OK;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
777 }
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
778 }
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
779
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
780 v->not_found = 1;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
781
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
782 return NGX_OK;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
783 }
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
784
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
785
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
786 static ngx_int_t
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
787 ngx_http_variable_host(ngx_http_request_t *r, ngx_http_variable_value_t *v,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
788 uintptr_t data)
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
789 {
362
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
790 ngx_http_core_srv_conf_t *cscf;
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
791
376
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
792 if (r->headers_in.server.len) {
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
793 v->len = r->headers_in.server.len;
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
794 v->data = r->headers_in.server.data;
270
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 258
diff changeset
795
6eb1e38f0f1f nginx 0.5.5
Igor Sysoev <http://sysoev.ru>
parents: 258
diff changeset
796 } else {
376
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
797 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
798
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
799 v->len = cscf->server_name.len;
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
800 v->data = cscf->server_name.data;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
801 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
802
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
803 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
804 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
805 v->not_found = 0;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
806
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
807 return NGX_OK;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
808 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
809
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
810
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
811 static ngx_int_t
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
812 ngx_http_variable_binary_remote_addr(ngx_http_request_t *r,
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
813 ngx_http_variable_value_t *v, uintptr_t data)
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
814 {
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
815 struct sockaddr_in *sin;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
816
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
817 /* AF_INET only */
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
818
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
819 sin = (struct sockaddr_in *) r->connection->sockaddr;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
820
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
821 v->len = sizeof(in_addr_t);
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
822 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
823 v->no_cacheable = 0;
272
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
824 v->not_found = 0;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
825 v->data = (u_char *) &sin->sin_addr.s_addr;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
826
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
827 return NGX_OK;
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
828 }
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
829
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
830
29a6403156b0 nginx 0.5.6
Igor Sysoev <http://sysoev.ru>
parents: 270
diff changeset
831 static ngx_int_t
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
832 ngx_http_variable_remote_addr(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
833 ngx_http_variable_value_t *v, uintptr_t data)
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
834 {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
835 v->len = r->connection->addr_text.len;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
836 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
837 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
838 v->not_found = 0;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
839 v->data = r->connection->addr_text.data;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
840
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
841 return NGX_OK;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
842 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
843
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
844
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
845 static ngx_int_t
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
846 ngx_http_variable_remote_port(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
847 ngx_http_variable_value_t *v, uintptr_t data)
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
848 {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
849 ngx_uint_t port;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
850 struct sockaddr_in *sin;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
851
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
852 v->len = 0;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
853 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
854 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
855 v->not_found = 0;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
856
382
984bb0b1399b nginx 0.7.3
Igor Sysoev <http://sysoev.ru>
parents: 376
diff changeset
857 v->data = ngx_pnalloc(r->pool, sizeof("65535") - 1);
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
858 if (v->data == NULL) {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
859 return NGX_ERROR;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
860 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
861
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
862 /* AF_INET only */
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
863
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
864 if (r->connection->sockaddr->sa_family == AF_INET) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
865 sin = (struct sockaddr_in *) r->connection->sockaddr;
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
866
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
867 port = ntohs(sin->sin_port);
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
868
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
869 if (port > 0 && port < 65536) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
870 v->len = ngx_sprintf(v->data, "%ui", port) - v->data;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
871 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
872 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
873
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
874 return NGX_OK;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
875 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
876
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
877
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
878 static ngx_int_t
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
879 ngx_http_variable_server_addr(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
880 ngx_http_variable_value_t *v, uintptr_t data)
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
881 {
362
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
882 ngx_str_t s;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
883
400
6ebbca3d5ed7 nginx 0.7.12
Igor Sysoev <http://sysoev.ru>
parents: 392
diff changeset
884 s.data = ngx_pnalloc(r->pool, NGX_INET_ADDRSTRLEN);
362
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
885 if (s.data == NULL) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
886 return NGX_ERROR;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
887 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
888
362
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
889 if (ngx_http_server_addr(r, &s) != NGX_OK) {
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
890 return NGX_ERROR;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
891 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
892
362
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
893 v->len = s.len;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
894 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
895 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
896 v->not_found = 0;
362
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
897 v->data = s.data;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
898
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
899 return NGX_OK;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
900 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
901
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
902
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
903 static ngx_int_t
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
904 ngx_http_variable_server_port(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
905 ngx_http_variable_value_t *v, uintptr_t data)
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
906 {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
907 v->len = r->port_text->len - 1;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
908 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
909 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
910 v->not_found = 0;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
911 v->data = r->port_text->data + 1;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
912
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
913 return NGX_OK;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
914 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
915
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
916
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
917 static ngx_int_t
238
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
918 ngx_http_variable_scheme(ngx_http_request_t *r,
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
919 ngx_http_variable_value_t *v, uintptr_t data)
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
920 {
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
921 #if (NGX_HTTP_SSL)
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
922
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
923 if (r->connection->ssl) {
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
924 v->len = sizeof("https") - 1;
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
925 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
926 v->no_cacheable = 0;
238
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
927 v->not_found = 0;
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
928 v->data = (u_char *) "https";
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
929
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
930 return NGX_OK;
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
931 }
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
932
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
933 #endif
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
934
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
935 v->len = sizeof("http") - 1;
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
936 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
937 v->no_cacheable = 0;
238
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
938 v->not_found = 0;
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
939 v->data = (u_char *) "http";
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
940
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
941 return NGX_OK;
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
942 }
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
943
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
944
a528ae0fe909 nginx 0.4.4
Igor Sysoev <http://sysoev.ru>
parents: 220
diff changeset
945 static ngx_int_t
324
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
946 ngx_http_variable_is_args(ngx_http_request_t *r,
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
947 ngx_http_variable_value_t *v, uintptr_t data)
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
948 {
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
949 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
950 v->no_cacheable = 0;
324
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
951 v->not_found = 0;
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
952
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
953 if (r->args.len == 0) {
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
954 v->len = 0;
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
955 v->data = NULL;
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
956 return NGX_OK;
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
957 }
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
958
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
959 v->len = 1;
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
960 v->data = (u_char *) "?";
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
961
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
962 return NGX_OK;
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
963 }
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
964
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
965
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
966 static ngx_int_t
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
967 ngx_http_variable_document_root(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
968 ngx_http_variable_value_t *v, uintptr_t data)
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
969 {
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
970 ngx_str_t path;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
971 ngx_http_core_loc_conf_t *clcf;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
972
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
973 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
974
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
975 if (clcf->root_lengths == NULL) {
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
976 v->len = clcf->root.len;
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
977 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
978 v->no_cacheable = 0;
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
979 v->not_found = 0;
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
980 v->data = clcf->root.data;
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
981
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
982 } else {
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
983 if (ngx_http_script_run(r, &path, clcf->root_lengths->elts, 0,
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
984 clcf->root_values->elts)
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
985 == NULL)
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
986 {
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
987 return NGX_ERROR;
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
988 }
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
989
324
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
990 if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &path, 0)
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
991 == NGX_ERROR)
f7cd062ee035 nginx 0.6.6
Igor Sysoev <http://sysoev.ru>
parents: 322
diff changeset
992 {
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
993 return NGX_ERROR;
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
994 }
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
995
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
996 v->len = path.len;
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
997 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
998 v->no_cacheable = 0;
220
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
999 v->not_found = 0;
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
1000 v->data = path.data;
559bc7ec214e nginx 0.3.57
Igor Sysoev <http://sysoev.ru>
parents: 216
diff changeset
1001 }
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1002
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1003 return NGX_OK;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1004 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1005
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1006
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1007 static ngx_int_t
412
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1008 ngx_http_variable_realpath_root(ngx_http_request_t *r,
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1009 ngx_http_variable_value_t *v, uintptr_t data)
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1010 {
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1011 size_t len;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1012 ngx_str_t path;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1013 ngx_http_core_loc_conf_t *clcf;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1014 u_char real[NGX_MAX_PATH];
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1015
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1016 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1017
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1018 if (clcf->root_lengths == NULL) {
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1019 path = clcf->root;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1020
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1021 } else {
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1022 if (ngx_http_script_run(r, &path, clcf->root_lengths->elts, 1,
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1023 clcf->root_values->elts)
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1024 == NULL)
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1025 {
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1026 return NGX_ERROR;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1027 }
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1028
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1029 path.data[path.len - 1] = '\0';
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1030
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1031 if (ngx_conf_full_name((ngx_cycle_t *) ngx_cycle, &path, 0)
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1032 == NGX_ERROR)
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1033 {
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1034 return NGX_ERROR;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1035 }
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1036 }
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1037
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1038 if (ngx_realpath(path.data, real) == NULL) {
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1039 ngx_log_error(NGX_LOG_CRIT, r->connection->log, ngx_errno,
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1040 ngx_realpath_n " \"%s\" failed", path.data);
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1041 return NGX_ERROR;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1042 }
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1043
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1044 len = ngx_strlen(real);
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1045
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1046 v->data = ngx_pnalloc(r->pool, len);
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1047 if (v->data == NULL) {
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1048 return NGX_ERROR;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1049 }
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1050
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1051 v->len = len;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1052 v->valid = 1;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1053 v->no_cacheable = 0;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1054 v->not_found = 0;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1055
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1056 ngx_memcpy(v->data, real, len);
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1057
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1058 return NGX_OK;
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1059 }
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1060
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1061
b246022ef454 nginx 0.7.18
Igor Sysoev <http://sysoev.ru>
parents: 410
diff changeset
1062 static ngx_int_t
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1063 ngx_http_variable_request_filename(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1064 ngx_http_variable_value_t *v, uintptr_t data)
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1065 {
248
acd2ec3541cb nginx 0.4.9
Igor Sysoev <http://sysoev.ru>
parents: 246
diff changeset
1066 size_t root;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1067 ngx_str_t path;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1068
248
acd2ec3541cb nginx 0.4.9
Igor Sysoev <http://sysoev.ru>
parents: 246
diff changeset
1069 if (ngx_http_map_uri_to_path(r, &path, &root, 0) == NULL) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1070 return NGX_ERROR;
106
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 102
diff changeset
1071 }
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1072
106
45f7329b4bd0 nginx 0.3.0
Igor Sysoev <http://sysoev.ru>
parents: 102
diff changeset
1073 /* ngx_http_map_uri_to_path() allocates memory for terminating '\0' */
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1074
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1075 v->len = path.len - 1;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1076 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1077 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1078 v->not_found = 0;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1079 v->data = path.data;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1080
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1081 return NGX_OK;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1082 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1083
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1084
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1085 static ngx_int_t
362
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1086 ngx_http_variable_server_name(ngx_http_request_t *r,
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1087 ngx_http_variable_value_t *v, uintptr_t data)
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1088 {
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1089 ngx_http_core_srv_conf_t *cscf;
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1090
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1091 cscf = ngx_http_get_module_srv_conf(r, ngx_http_core_module);
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1092
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1093 v->len = cscf->server_name.len;
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1094 v->valid = 1;
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1095 v->no_cacheable = 0;
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1096 v->not_found = 0;
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1097 v->data = cscf->server_name.data;
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1098
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1099 return NGX_OK;
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1100 }
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1101
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1102
54fad6c4b555 nginx 0.6.25
Igor Sysoev <http://sysoev.ru>
parents: 340
diff changeset
1103 static ngx_int_t
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1104 ngx_http_variable_request_method(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1105 ngx_http_variable_value_t *v, uintptr_t data)
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 106
diff changeset
1106 {
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
1107 if (r->main->method_name.data) {
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
1108 v->len = r->main->method_name.len;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1109 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1110 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1111 v->not_found = 0;
196
8759b346e431 nginx 0.3.45
Igor Sysoev <http://sysoev.ru>
parents: 190
diff changeset
1112 v->data = r->main->method_name.data;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1113
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1114 } else {
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1115 v->not_found = 1;
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 106
diff changeset
1116 }
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 106
diff changeset
1117
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1118 return NGX_OK;
110
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 106
diff changeset
1119 }
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 106
diff changeset
1120
dad2fe8ecf08 nginx 0.3.2
Igor Sysoev <http://sysoev.ru>
parents: 106
diff changeset
1121
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1122 static ngx_int_t
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1123 ngx_http_variable_remote_user(ngx_http_request_t *r,
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1124 ngx_http_variable_value_t *v, uintptr_t data)
88
e916a291e9aa nginx 0.1.44
Igor Sysoev <http://sysoev.ru>
parents: 82
diff changeset
1125 {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1126 ngx_int_t rc;
88
e916a291e9aa nginx 0.1.44
Igor Sysoev <http://sysoev.ru>
parents: 82
diff changeset
1127
e916a291e9aa nginx 0.1.44
Igor Sysoev <http://sysoev.ru>
parents: 82
diff changeset
1128 rc = ngx_http_auth_basic_user(r);
e916a291e9aa nginx 0.1.44
Igor Sysoev <http://sysoev.ru>
parents: 82
diff changeset
1129
e916a291e9aa nginx 0.1.44
Igor Sysoev <http://sysoev.ru>
parents: 82
diff changeset
1130 if (rc == NGX_DECLINED) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1131 v->not_found = 1;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1132 return NGX_OK;
88
e916a291e9aa nginx 0.1.44
Igor Sysoev <http://sysoev.ru>
parents: 82
diff changeset
1133 }
e916a291e9aa nginx 0.1.44
Igor Sysoev <http://sysoev.ru>
parents: 82
diff changeset
1134
e916a291e9aa nginx 0.1.44
Igor Sysoev <http://sysoev.ru>
parents: 82
diff changeset
1135 if (rc == NGX_ERROR) {
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1136 return NGX_ERROR;
88
e916a291e9aa nginx 0.1.44
Igor Sysoev <http://sysoev.ru>
parents: 82
diff changeset
1137 }
e916a291e9aa nginx 0.1.44
Igor Sysoev <http://sysoev.ru>
parents: 82
diff changeset
1138
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1139 v->len = r->headers_in.user.len;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1140 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1141 v->no_cacheable = 0;
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1142 v->not_found = 0;
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1143 v->data = r->headers_in.user.data;
120
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
1144
122
d25a1d6034f1 nginx 0.3.8
Igor Sysoev <http://sysoev.ru>
parents: 120
diff changeset
1145 return NGX_OK;
120
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
1146 }
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
1147
e85dca77c46a nginx 0.3.7
Igor Sysoev <http://sysoev.ru>
parents: 118
diff changeset
1148
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1149 static ngx_int_t
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1150 ngx_http_variable_body_bytes_sent(ngx_http_request_t *r,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1151 ngx_http_variable_value_t *v, uintptr_t data)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1152 {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1153 off_t sent;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1154 u_char *p;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1155
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1156 sent = r->connection->sent - r->header_size;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1157
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1158 if (sent < 0) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1159 sent = 0;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1160 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1161
382
984bb0b1399b nginx 0.7.3
Igor Sysoev <http://sysoev.ru>
parents: 376
diff changeset
1162 p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN);
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1163 if (p == NULL) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1164 return NGX_ERROR;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1165 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1166
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1167 v->len = ngx_sprintf(p, "%O", sent) - p;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1168 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1169 v->no_cacheable = 0;
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1170 v->not_found = 0;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1171 v->data = p;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1172
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1173 return NGX_OK;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1174 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1175
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1176
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1177 static ngx_int_t
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1178 ngx_http_variable_sent_content_type(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1179 ngx_http_variable_value_t *v, uintptr_t data)
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1180 {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1181 if (r->headers_out.content_type.len) {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1182 v->len = r->headers_out.content_type.len;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1183 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1184 v->no_cacheable = 0;
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1185 v->not_found = 0;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1186 v->data = r->headers_out.content_type.data;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1187
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1188 } else {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1189 v->not_found = 1;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1190 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1191
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1192 return NGX_OK;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1193 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1194
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1195
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1196 static ngx_int_t
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1197 ngx_http_variable_sent_content_length(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1198 ngx_http_variable_value_t *v, uintptr_t data)
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1199 {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1200 u_char *p;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1201
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1202 if (r->headers_out.content_length) {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1203 v->len = r->headers_out.content_length->value.len;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1204 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1205 v->no_cacheable = 0;
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1206 v->not_found = 0;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1207 v->data = r->headers_out.content_length->value.data;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1208
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1209 return NGX_OK;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1210 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1211
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1212 if (r->headers_out.content_length_n >= 0) {
382
984bb0b1399b nginx 0.7.3
Igor Sysoev <http://sysoev.ru>
parents: 376
diff changeset
1213 p = ngx_pnalloc(r->pool, NGX_OFF_T_LEN);
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1214 if (p == NULL) {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1215 return NGX_ERROR;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1216 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1217
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1218 v->len = ngx_sprintf(p, "%O", r->headers_out.content_length_n) - p;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1219 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1220 v->no_cacheable = 0;
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1221 v->not_found = 0;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1222 v->data = p;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1223
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1224 return NGX_OK;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1225 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1226
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1227 v->not_found = 1;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1228
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1229 return NGX_OK;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1230 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1231
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1232
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1233 static ngx_int_t
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1234 ngx_http_variable_sent_last_modified(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1235 ngx_http_variable_value_t *v, uintptr_t data)
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1236 {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1237 u_char *p;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1238
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1239 if (r->headers_out.last_modified) {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1240 v->len = r->headers_out.last_modified->value.len;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1241 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1242 v->no_cacheable = 0;
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1243 v->not_found = 0;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1244 v->data = r->headers_out.last_modified->value.data;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1245
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1246 return NGX_OK;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1247 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1248
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1249 if (r->headers_out.last_modified_time >= 0) {
382
984bb0b1399b nginx 0.7.3
Igor Sysoev <http://sysoev.ru>
parents: 376
diff changeset
1250 p = ngx_pnalloc(r->pool,
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1251 sizeof("Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT") - 1);
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1252 if (p == NULL) {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1253 return NGX_ERROR;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1254 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1255
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1256 v->len = ngx_http_time(p, r->headers_out.last_modified_time) - p;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1257 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1258 v->no_cacheable = 0;
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1259 v->not_found = 0;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1260 v->data = p;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1261
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1262 return NGX_OK;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1263 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1264
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1265 v->not_found = 1;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1266
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1267 return NGX_OK;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1268 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1269
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1270
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1271 static ngx_int_t
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1272 ngx_http_variable_sent_connection(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1273 ngx_http_variable_value_t *v, uintptr_t data)
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1274 {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1275 size_t len;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1276 char *p;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1277
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1278 if (r->keepalive) {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1279 len = sizeof("keep-alive") - 1;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1280 p = "keep-alive";
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1281
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1282 } else {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1283 len = sizeof("close") - 1;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1284 p = "close";
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1285 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1286
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1287 v->len = len;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1288 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1289 v->no_cacheable = 0;
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1290 v->not_found = 0;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1291 v->data = (u_char *) p;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1292
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1293 return NGX_OK;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1294 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1295
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1296
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1297 static ngx_int_t
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1298 ngx_http_variable_sent_keep_alive(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1299 ngx_http_variable_value_t *v, uintptr_t data)
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1300 {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1301 u_char *p;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1302 ngx_http_core_loc_conf_t *clcf;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1303
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1304 if (r->keepalive) {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1305 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module);
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1306
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1307 if (clcf->keepalive_header) {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1308
382
984bb0b1399b nginx 0.7.3
Igor Sysoev <http://sysoev.ru>
parents: 376
diff changeset
1309 p = ngx_pnalloc(r->pool, sizeof("timeout=") - 1 + NGX_TIME_T_LEN);
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1310 if (p == NULL) {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1311 return NGX_ERROR;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1312 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1313
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1314 v->len = ngx_sprintf(p, "timeout=%T", clcf->keepalive_header) - p;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1315 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1316 v->no_cacheable = 0;
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1317 v->not_found = 0;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1318 v->data = p;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1319
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1320 return NGX_OK;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1321 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1322 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1323
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1324 v->not_found = 1;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1325
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1326 return NGX_OK;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1327 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1328
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1329
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1330 static ngx_int_t
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1331 ngx_http_variable_sent_transfer_encoding(ngx_http_request_t *r,
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1332 ngx_http_variable_value_t *v, uintptr_t data)
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1333 {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1334 if (r->chunked) {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1335 v->len = sizeof("chunked") - 1;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1336 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1337 v->no_cacheable = 0;
190
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1338 v->not_found = 0;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1339 v->data = (u_char *) "chunked";
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1340
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1341 } else {
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1342 v->not_found = 1;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1343 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1344
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1345 return NGX_OK;
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1346 }
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1347
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1348
3689cd4e3228 nginx 0.3.42
Igor Sysoev <http://sysoev.ru>
parents: 186
diff changeset
1349 static ngx_int_t
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1350 ngx_http_variable_request_completion(ngx_http_request_t *r,
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1351 ngx_http_variable_value_t *v, uintptr_t data)
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1352 {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1353 if (r->request_complete) {
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1354 v->len = 2;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1355 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1356 v->no_cacheable = 0;
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1357 v->not_found = 0;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1358 v->data = (u_char *) "OK";
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1359
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1360 return NGX_OK;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1361 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1362
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1363 v->len = 0;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1364 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1365 v->no_cacheable = 0;
178
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1366 v->not_found = 0;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1367 v->data = (u_char *) "";
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1368
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1369 return NGX_OK;
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1370 }
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1371
87699398f955 nginx 0.3.36
Igor Sysoev <http://sysoev.ru>
parents: 160
diff changeset
1372
244
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1373 static ngx_int_t
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1374 ngx_http_variable_request_body_file(ngx_http_request_t *r,
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1375 ngx_http_variable_value_t *v, uintptr_t data)
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1376 {
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1377 if (r->request_body == NULL || r->request_body->temp_file == NULL) {
246
b52bd034c577 nginx 0.4.8
Igor Sysoev <http://sysoev.ru>
parents: 244
diff changeset
1378 v->not_found = 1;
244
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1379
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1380 return NGX_OK;
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1381 }
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1382
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1383 v->len = r->request_body->temp_file->file.name.len;
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1384 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1385 v->no_cacheable = 0;
244
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1386 v->not_found = 0;
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1387 v->data = r->request_body->temp_file->file.name.data;
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1388
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1389 return NGX_OK;
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1390 }
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1391
500a3242dff6 nginx 0.4.7
Igor Sysoev <http://sysoev.ru>
parents: 242
diff changeset
1392
322
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1393 static ngx_int_t
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1394 ngx_http_variable_nginx_version(ngx_http_request_t *r,
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1395 ngx_http_variable_value_t *v, uintptr_t data)
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1396 {
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1397 v->len = sizeof(NGINX_VERSION) - 1;
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1398 v->valid = 1;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1399 v->no_cacheable = 0;
322
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1400 v->not_found = 0;
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1401 v->data = (u_char *) NGINX_VERSION;
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1402
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1403 return NGX_OK;
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1404 }
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1405
d16d691432c9 nginx 0.6.5
Igor Sysoev <http://sysoev.ru>
parents: 320
diff changeset
1406
376
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1407 static ngx_int_t
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1408 ngx_http_variable_hostname(ngx_http_request_t *r,
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1409 ngx_http_variable_value_t *v, uintptr_t data)
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1410 {
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1411 v->len = ngx_cycle->hostname.len;
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1412 v->valid = 1;
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1413 v->no_cacheable = 0;
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1414 v->not_found = 0;
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1415 v->data = ngx_cycle->hostname.data;
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1416
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1417 return NGX_OK;
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1418 }
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1419
edf1cb6c328e nginx 0.7.0
Igor Sysoev <http://sysoev.ru>
parents: 362
diff changeset
1420
410
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1421 static ngx_int_t
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1422 ngx_http_variable_pid(ngx_http_request_t *r,
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1423 ngx_http_variable_value_t *v, uintptr_t data)
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1424 {
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1425 u_char *p;
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1426
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1427 p = ngx_pnalloc(r->pool, NGX_INT64_LEN);
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1428 if (p == NULL) {
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1429 return NGX_ERROR;
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1430 }
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1431
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1432 v->len = ngx_sprintf(p, "%P", ngx_pid) - p;
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1433 v->valid = 1;
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1434 v->no_cacheable = 0;
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1435 v->not_found = 0;
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1436 v->data = p;
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1437
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1438 return NGX_OK;
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1439 }
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1440
a8e3f1441eec nginx 0.7.17
Igor Sysoev <http://sysoev.ru>
parents: 406
diff changeset
1441
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1442 ngx_int_t
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1443 ngx_http_variables_add_core_vars(ngx_conf_t *cf)
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1444 {
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1445 ngx_int_t rc;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1446 ngx_http_variable_t *v;
50
72eb30262aac nginx 0.1.25
Igor Sysoev <http://sysoev.ru>
parents: 48
diff changeset
1447 ngx_http_core_main_conf_t *cmcf;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1448
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1449 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1450
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1451 cmcf->variables_keys = ngx_pcalloc(cf->temp_pool,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1452 sizeof(ngx_hash_keys_arrays_t));
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1453 if (cmcf->variables_keys == NULL) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1454 return NGX_ERROR;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1455 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1456
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1457 cmcf->variables_keys->pool = cf->pool;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1458 cmcf->variables_keys->temp_pool = cf->pool;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1459
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1460 if (ngx_hash_keys_array_init(cmcf->variables_keys, NGX_HASH_SMALL)
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1461 != NGX_OK)
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1462 {
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1463 return NGX_ERROR;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1464 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1465
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1466 for (v = ngx_http_core_variables; v->name.len; v++) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1467 rc = ngx_hash_add_key(cmcf->variables_keys, &v->name, v,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1468 NGX_HASH_READONLY_KEY);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1469
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1470 if (rc == NGX_OK) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1471 continue;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1472 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1473
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1474 if (rc == NGX_BUSY) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1475 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1476 "conflicting variable name \"%V\"", &v->name);
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1477 }
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1478
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1479 return NGX_ERROR;
48
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1480 }
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1481
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1482 return NGX_OK;
6cfc63e68377 nginx 0.1.24
Igor Sysoev <http://sysoev.ru>
parents:
diff changeset
1483 }
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1484
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1485
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1486 ngx_int_t
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1487 ngx_http_variables_init_vars(ngx_conf_t *cf)
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1488 {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1489 ngx_uint_t i, n;
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1490 ngx_hash_key_t *key;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1491 ngx_hash_init_t hash;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1492 ngx_http_variable_t *v, *av;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1493 ngx_http_core_main_conf_t *cmcf;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1494
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1495 /* set the handlers for the indexed http variables */
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1496
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1497 cmcf = ngx_http_conf_get_module_main_conf(cf, ngx_http_core_module);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1498
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1499 v = cmcf->variables.elts;
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1500 key = cmcf->variables_keys->keys.elts;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1501
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1502 for (i = 0; i < cmcf->variables.nelts; i++) {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1503
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1504 for (n = 0; n < cmcf->variables_keys->keys.nelts; n++) {
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1505
300
cba14c1e2a4b nginx 0.5.20
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
1506 av = key[n].value;
cba14c1e2a4b nginx 0.5.20
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
1507
cba14c1e2a4b nginx 0.5.20
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
1508 if (av->get_handler
cba14c1e2a4b nginx 0.5.20
Igor Sysoev <http://sysoev.ru>
parents: 296
diff changeset
1509 && v[i].name.len == key[n].key.len
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1510 && ngx_strncmp(v[i].name.data, key[n].key.data, v[i].name.len)
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1511 == 0)
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1512 {
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
1513 v[i].get_handler = av->get_handler;
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1514 v[i].data = av->data;
76
da9a3b14312d nginx 0.1.38
Igor Sysoev <http://sysoev.ru>
parents: 68
diff changeset
1515
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1516 av->flags |= NGX_HTTP_VAR_INDEXED;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1517 v[i].flags = av->flags;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1518
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1519 av->index = i;
82
2aa14f638cf0 nginx 0.1.41
Igor Sysoev <http://sysoev.ru>
parents: 76
diff changeset
1520
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1521 goto next;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1522 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1523 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1524
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1525 if (ngx_strncmp(v[i].name.data, "http_", 5) == 0) {
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
1526 v[i].get_handler = ngx_http_variable_unknown_header_in;
126
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
1527 v[i].data = (uintptr_t) &v[i].name;
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
1528
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
1529 continue;
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
1530 }
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
1531
df17fbafec8f nginx 0.3.10
Igor Sysoev <http://sysoev.ru>
parents: 122
diff changeset
1532 if (ngx_strncmp(v[i].name.data, "sent_http_", 10) == 0) {
186
54aabf2b0bc6 nginx 0.3.40
Igor Sysoev <http://sysoev.ru>
parents: 184
diff changeset
1533 v[i].get_handler = ngx_http_variable_unknown_header_out;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1534 v[i].data = (uintptr_t) &v[i].name;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1535
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1536 continue;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1537 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1538
296
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
1539 if (ngx_strncmp(v[i].name.data, "upstream_http_", 14) == 0) {
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
1540 v[i].get_handler = ngx_http_upstream_header_variable;
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
1541 v[i].data = (uintptr_t) &v[i].name;
340
10cc350ed8a1 nginx 0.6.14
Igor Sysoev <http://sysoev.ru>
parents: 324
diff changeset
1542 v[i].flags = NGX_HTTP_VAR_NOCACHEABLE;
296
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
1543
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
1544 continue;
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
1545 }
2ceaee987f37 nginx 0.5.18
Igor Sysoev <http://sysoev.ru>
parents: 294
diff changeset
1546
392
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
1547 if (ngx_strncmp(v[i].name.data, "arg_", 4) == 0) {
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
1548 v[i].get_handler = ngx_http_variable_argument;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
1549 v[i].data = (uintptr_t) &v[i].name;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
1550
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
1551 continue;
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
1552 }
34fb3a573548 nginx 0.7.8
Igor Sysoev <http://sysoev.ru>
parents: 382
diff changeset
1553
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1554 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1555 "unknown \"%V\" variable", &v[i].name);
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1556
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1557 return NGX_ERROR;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1558
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1559 next:
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1560 continue;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1561 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1562
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1563
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1564 for (n = 0; n < cmcf->variables_keys->keys.nelts; n++) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1565 av = key[n].value;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1566
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1567 if (av->flags & NGX_HTTP_VAR_NOHASH) {
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1568 key[n].key.data = NULL;
132
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 130
diff changeset
1569 }
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 130
diff changeset
1570 }
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 130
diff changeset
1571
91372f004adf nginx 0.3.13
Igor Sysoev <http://sysoev.ru>
parents: 130
diff changeset
1572
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1573 hash.hash = &cmcf->variables_hash;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1574 hash.key = ngx_hash_key;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1575 hash.max_size = cmcf->variables_hash_max_size;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1576 hash.bucket_size = cmcf->variables_hash_bucket_size;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1577 hash.name = "variables_hash";
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1578 hash.pool = cf->pool;
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1579 hash.temp_pool = NULL;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1580
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1581 if (ngx_hash_init(&hash, cmcf->variables_keys->keys.elts,
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1582 cmcf->variables_keys->keys.nelts)
130
82d695e3d662 nginx 0.3.12
Igor Sysoev <http://sysoev.ru>
parents: 126
diff changeset
1583 != NGX_OK)
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1584 {
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1585 return NGX_ERROR;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1586 }
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1587
160
73e8476f9142 nginx 0.3.27
Igor Sysoev <http://sysoev.ru>
parents: 138
diff changeset
1588 cmcf->variables_keys = NULL;
58
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1589
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1590 return NGX_OK;
b55cbf18157e nginx 0.1.29
Igor Sysoev <http://sysoev.ru>
parents: 50
diff changeset
1591 }