Mercurial > hg > nginx-mail
comparison src/http/ngx_http_variables.c @ 82:2aa14f638cf0 NGINX_0_1_41
nginx 0.1.41
*) Bugfix: if the variable was used in the configuration file, then it
can not be used in SSI.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 25 Jul 2005 00:00:00 +0400 |
parents | da9a3b14312d |
children | e916a291e9aa |
comparison
equal
deleted
inserted
replaced
81:4e854e6d1986 | 82:2aa14f638cf0 |
---|---|
45 */ | 45 */ |
46 | 46 |
47 static ngx_http_variable_t ngx_http_core_variables[] = { | 47 static ngx_http_variable_t ngx_http_core_variables[] = { |
48 | 48 |
49 { ngx_string("http_host"), ngx_http_variable_header, | 49 { ngx_string("http_host"), ngx_http_variable_header, |
50 offsetof(ngx_http_request_t, headers_in.host), 0 }, | 50 offsetof(ngx_http_request_t, headers_in.host), 0, 0 }, |
51 | 51 |
52 { ngx_string("http_user_agent"), ngx_http_variable_header, | 52 { ngx_string("http_user_agent"), ngx_http_variable_header, |
53 offsetof(ngx_http_request_t, headers_in.user_agent), 0 }, | 53 offsetof(ngx_http_request_t, headers_in.user_agent), 0, 0 }, |
54 | 54 |
55 { ngx_string("http_referer"), ngx_http_variable_header, | 55 { ngx_string("http_referer"), ngx_http_variable_header, |
56 offsetof(ngx_http_request_t, headers_in.referer), 0 }, | 56 offsetof(ngx_http_request_t, headers_in.referer), 0, 0 }, |
57 | 57 |
58 #if (NGX_HTTP_GZIP) | 58 #if (NGX_HTTP_GZIP) |
59 { ngx_string("http_via"), ngx_http_variable_header, | 59 { ngx_string("http_via"), ngx_http_variable_header, |
60 offsetof(ngx_http_request_t, headers_in.via), 0 }, | 60 offsetof(ngx_http_request_t, headers_in.via), 0, 0 }, |
61 #endif | 61 #endif |
62 | 62 |
63 #if (NGX_HTTP_PROXY) | 63 #if (NGX_HTTP_PROXY) |
64 { ngx_string("http_x_forwarded_for"), ngx_http_variable_header, | 64 { ngx_string("http_x_forwarded_for"), ngx_http_variable_header, |
65 offsetof(ngx_http_request_t, headers_in.x_forwarded_for), 0 }, | 65 offsetof(ngx_http_request_t, headers_in.x_forwarded_for), 0, 0 }, |
66 #endif | 66 #endif |
67 | 67 |
68 { ngx_string("http_cookie"), ngx_http_variable_headers, | 68 { ngx_string("http_cookie"), ngx_http_variable_headers, |
69 offsetof(ngx_http_request_t, headers_in.cookies), 0 }, | 69 offsetof(ngx_http_request_t, headers_in.cookies), 0, 0 }, |
70 | 70 |
71 { ngx_string("content_length"), ngx_http_variable_header, | 71 { ngx_string("content_length"), ngx_http_variable_header, |
72 offsetof(ngx_http_request_t, headers_in.content_length), 0 }, | 72 offsetof(ngx_http_request_t, headers_in.content_length), 0, 0 }, |
73 | 73 |
74 { ngx_string("content_type"), ngx_http_variable_header, | 74 { ngx_string("content_type"), ngx_http_variable_header, |
75 offsetof(ngx_http_request_t, headers_in.content_type), 0 }, | 75 offsetof(ngx_http_request_t, headers_in.content_type), 0, 0 }, |
76 | 76 |
77 { ngx_string("host"), ngx_http_variable_host, 0, 0 }, | 77 { ngx_string("host"), ngx_http_variable_host, 0, 0, 0 }, |
78 | 78 |
79 { ngx_string("remote_addr"), ngx_http_variable_remote_addr, 0, 0 }, | 79 { ngx_string("remote_addr"), ngx_http_variable_remote_addr, 0, 0, 0 }, |
80 | 80 |
81 { ngx_string("remote_port"), ngx_http_variable_remote_port, 0, 0 }, | 81 { ngx_string("remote_port"), ngx_http_variable_remote_port, 0, 0, 0 }, |
82 | 82 |
83 { ngx_string("server_addr"), ngx_http_variable_server_addr, 0, 0 }, | 83 { ngx_string("server_addr"), ngx_http_variable_server_addr, 0, 0, 0 }, |
84 | 84 |
85 { ngx_string("server_port"), ngx_http_variable_server_port, 0, 0 }, | 85 { ngx_string("server_port"), ngx_http_variable_server_port, 0, 0, 0 }, |
86 | 86 |
87 { ngx_string("server_protocol"), ngx_http_variable_request, | 87 { ngx_string("server_protocol"), ngx_http_variable_request, |
88 offsetof(ngx_http_request_t, http_protocol), 0 }, | 88 offsetof(ngx_http_request_t, http_protocol), 0, 0 }, |
89 | 89 |
90 { ngx_string("request_uri"), ngx_http_variable_request, | 90 { ngx_string("request_uri"), ngx_http_variable_request, |
91 offsetof(ngx_http_request_t, unparsed_uri), 0 }, | 91 offsetof(ngx_http_request_t, unparsed_uri), 0, 0 }, |
92 | 92 |
93 { ngx_string("document_uri"), ngx_http_variable_request, | 93 { ngx_string("document_uri"), ngx_http_variable_request, |
94 offsetof(ngx_http_request_t, uri), 0 }, | 94 offsetof(ngx_http_request_t, uri), 0, 0 }, |
95 | 95 |
96 { ngx_string("document_root"), ngx_http_variable_document_root, 0, 0 }, | 96 { ngx_string("document_root"), ngx_http_variable_document_root, 0, 0, 0 }, |
97 | 97 |
98 { ngx_string("query_string"), ngx_http_variable_request, | 98 { ngx_string("query_string"), ngx_http_variable_request, |
99 offsetof(ngx_http_request_t, args), | 99 offsetof(ngx_http_request_t, args), |
100 NGX_HTTP_VAR_NOCACHABLE }, | 100 NGX_HTTP_VAR_NOCACHABLE, 0 }, |
101 | 101 |
102 { ngx_string("request_filename"), ngx_http_variable_request_filename, 0, | 102 { ngx_string("request_filename"), ngx_http_variable_request_filename, 0, |
103 NGX_HTTP_VAR_NOCACHABLE }, | 103 NGX_HTTP_VAR_NOCACHABLE, 0 }, |
104 | 104 |
105 { ngx_string("server_name"), ngx_http_variable_request, | 105 { ngx_string("server_name"), ngx_http_variable_request, |
106 offsetof(ngx_http_request_t, server_name), 0 }, | 106 offsetof(ngx_http_request_t, server_name), 0, 0 }, |
107 | 107 |
108 { ngx_string("request_method"), ngx_http_variable_request, | 108 { ngx_string("request_method"), ngx_http_variable_request, |
109 offsetof(ngx_http_request_t, method_name), 0 }, | 109 offsetof(ngx_http_request_t, method_name), 0, 0 }, |
110 | 110 |
111 { ngx_string("remote_user"), ngx_http_variable_request, | 111 { ngx_string("remote_user"), ngx_http_variable_request, |
112 offsetof(ngx_http_request_t, headers_in.user), 0 }, | 112 offsetof(ngx_http_request_t, headers_in.user), 0, 0 }, |
113 | 113 |
114 { ngx_null_string, NULL, 0, 0 } | 114 { ngx_null_string, NULL, 0, 0, 0 } |
115 }; | 115 }; |
116 | 116 |
117 | 117 |
118 ngx_http_variable_t * | 118 ngx_http_variable_t * |
119 ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name, ngx_uint_t flags) | 119 ngx_http_add_variable(ngx_conf_t *cf, ngx_str_t *name, ngx_uint_t flags) |
157 } | 157 } |
158 | 158 |
159 v->handler = NULL; | 159 v->handler = NULL; |
160 v->data = 0; | 160 v->data = 0; |
161 v->flags = flags; | 161 v->flags = flags; |
162 v->index = 0; | |
162 | 163 |
163 return v; | 164 return v; |
164 } | 165 } |
165 | 166 |
166 | 167 |
210 } | 211 } |
211 | 212 |
212 v->handler = NULL; | 213 v->handler = NULL; |
213 v->data = 0; | 214 v->data = 0; |
214 v->flags = 0; | 215 v->flags = 0; |
216 v->index = cmcf->variables.nelts - 1; | |
215 | 217 |
216 return cmcf->variables.nelts - 1; | 218 return cmcf->variables.nelts - 1; |
217 } | 219 } |
218 | 220 |
219 | 221 |
275 | 277 |
276 if (v[key].name.len == name->len | 278 if (v[key].name.len == name->len |
277 && ngx_strncmp(v[key].name.data, name->data, name->len) == 0) | 279 && ngx_strncmp(v[key].name.data, name->data, name->len) == 0) |
278 { | 280 { |
279 if (v[key].flags & NGX_HTTP_VAR_INDEXED) { | 281 if (v[key].flags & NGX_HTTP_VAR_INDEXED) { |
280 return ngx_http_get_indexed_variable(r, v[key].data); | 282 return ngx_http_get_indexed_variable(r, v[key].index); |
281 | 283 |
282 } else { | 284 } else { |
283 return v[key].handler(r, v[key].data); | 285 return v[key].handler(r, v[key].data); |
284 } | 286 } |
285 } | 287 } |
708 v[i].data = av[n].data; | 710 v[i].data = av[n].data; |
709 | 711 |
710 av[n].flags |= NGX_HTTP_VAR_INDEXED; | 712 av[n].flags |= NGX_HTTP_VAR_INDEXED; |
711 v[i].flags = av[n].flags; | 713 v[i].flags = av[n].flags; |
712 | 714 |
715 av[n].index = i; | |
716 | |
713 goto next; | 717 goto next; |
714 } | 718 } |
715 } | 719 } |
716 | 720 |
717 if (ngx_strncmp(v[i].name.data, "http_", 5) == 0) { | 721 if (ngx_strncmp(v[i].name.data, "http_", 5) == 0) { |