42 #if (NGX_HAVE_TCP_INFO)
149 {
ngx_string(
"http_host"), NULL, ngx_http_variable_header,
152 {
ngx_string(
"http_user_agent"), NULL, ngx_http_variable_header,
155 {
ngx_string(
"http_referer"), NULL, ngx_http_variable_header,
159 {
ngx_string(
"http_via"), NULL, ngx_http_variable_header,
163 #if (NGX_HTTP_X_FORWARDED_FOR)
164 {
ngx_string(
"http_x_forwarded_for"), NULL, ngx_http_variable_headers,
168 {
ngx_string(
"http_cookie"), NULL, ngx_http_variable_cookies,
171 {
ngx_string(
"content_length"), NULL, ngx_http_variable_content_length,
174 {
ngx_string(
"content_type"), NULL, ngx_http_variable_header,
177 {
ngx_string(
"host"), NULL, ngx_http_variable_host, 0, 0, 0 },
180 ngx_http_variable_binary_remote_addr, 0, 0, 0 },
182 {
ngx_string(
"remote_addr"), NULL, ngx_http_variable_remote_addr, 0, 0, 0 },
184 {
ngx_string(
"remote_port"), NULL, ngx_http_variable_remote_port, 0, 0, 0 },
186 {
ngx_string(
"server_addr"), NULL, ngx_http_variable_server_addr, 0, 0, 0 },
188 {
ngx_string(
"server_port"), NULL, ngx_http_variable_server_port, 0, 0, 0 },
190 {
ngx_string(
"server_protocol"), NULL, ngx_http_variable_request,
193 {
ngx_string(
"scheme"), NULL, ngx_http_variable_scheme, 0, 0, 0 },
195 {
ngx_string(
"https"), NULL, ngx_http_variable_https, 0, 0, 0 },
197 {
ngx_string(
"request_uri"), NULL, ngx_http_variable_request,
200 {
ngx_string(
"uri"), NULL, ngx_http_variable_request,
204 {
ngx_string(
"document_uri"), NULL, ngx_http_variable_request,
208 {
ngx_string(
"request"), NULL, ngx_http_variable_request_line, 0, 0, 0 },
216 {
ngx_string(
"query_string"), NULL, ngx_http_variable_request,
221 ngx_http_variable_request_set,
222 ngx_http_variable_request,
226 {
ngx_string(
"is_args"), NULL, ngx_http_variable_is_args,
230 ngx_http_variable_request_filename, 0,
233 {
ngx_string(
"server_name"), NULL, ngx_http_variable_server_name, 0, 0, 0 },
236 ngx_http_variable_request_method, 0,
239 {
ngx_string(
"remote_user"), NULL, ngx_http_variable_remote_user, 0, 0, 0 },
241 {
ngx_string(
"bytes_sent"), NULL, ngx_http_variable_bytes_sent,
244 {
ngx_string(
"body_bytes_sent"), NULL, ngx_http_variable_body_bytes_sent,
247 {
ngx_string(
"pipe"), NULL, ngx_http_variable_pipe,
251 ngx_http_variable_request_completion,
255 ngx_http_variable_request_body,
259 ngx_http_variable_request_body_file,
262 {
ngx_string(
"request_length"), NULL, ngx_http_variable_request_length,
265 {
ngx_string(
"request_time"), NULL, ngx_http_variable_request_time,
269 ngx_http_variable_status, 0,
273 ngx_http_variable_sent_content_type, 0, 0, 0 },
275 {
ngx_string(
"sent_http_content_length"), NULL,
276 ngx_http_variable_sent_content_length, 0, 0, 0 },
279 ngx_http_variable_sent_location, 0, 0, 0 },
281 {
ngx_string(
"sent_http_last_modified"), NULL,
282 ngx_http_variable_sent_last_modified, 0, 0, 0 },
285 ngx_http_variable_sent_connection, 0, 0, 0 },
288 ngx_http_variable_sent_keep_alive, 0, 0, 0 },
290 {
ngx_string(
"sent_http_transfer_encoding"), NULL,
291 ngx_http_variable_sent_transfer_encoding, 0, 0, 0 },
293 {
ngx_string(
"sent_http_cache_control"), NULL, ngx_http_variable_headers,
296 {
ngx_string(
"limit_rate"), ngx_http_variable_request_set_size,
297 ngx_http_variable_request_get_size,
302 ngx_http_variable_connection, 0, 0, 0 },
305 ngx_http_variable_connection_requests, 0, 0, 0 },
307 {
ngx_string(
"nginx_version"), NULL, ngx_http_variable_nginx_version,
310 {
ngx_string(
"hostname"), NULL, ngx_http_variable_hostname,
313 {
ngx_string(
"pid"), NULL, ngx_http_variable_pid,
316 {
ngx_string(
"msec"), NULL, ngx_http_variable_msec,
319 {
ngx_string(
"time_iso8601"), NULL, ngx_http_variable_time_iso8601,
322 {
ngx_string(
"time_local"), NULL, ngx_http_variable_time_local,
325 #if (NGX_HAVE_TCP_INFO)
326 {
ngx_string(
"tcpinfo_rtt"), NULL, ngx_http_variable_tcpinfo,
329 {
ngx_string(
"tcpinfo_rttvar"), NULL, ngx_http_variable_tcpinfo,
332 {
ngx_string(
"tcpinfo_snd_cwnd"), NULL, ngx_http_variable_tcpinfo,
335 {
ngx_string(
"tcpinfo_rcv_space"), NULL, ngx_http_variable_tcpinfo,
358 if (name->
len == 0) {
360 "invalid variable name \"$\"");
378 "the duplicate \"%V\" variable", name);
412 "conflicting variable name \"%V\"", name);
427 if (name->
len == 0) {
429 "invalid variable name \"$\"");
490 "unknown variable index: %d", index);
500 if (v[index].get_handler(r, &r->
variables[index], v[index].
data)
571 if (ngx_http_variable_unknown_header_in(r, vv, (uintptr_t) name)
582 if (ngx_http_variable_unknown_header_out(r, vv, (uintptr_t) name)
604 if (ngx_http_variable_cookie(r, vv, (uintptr_t) name) ==
NGX_OK) {
613 if (ngx_http_variable_argument(r, vv, (uintptr_t) name) ==
NGX_OK) {
668 sp = (
size_t *) ((
char *) r + data);
671 if (v->
data == NULL) {
698 "invalid size \"%V\"", &val);
702 sp = (ssize_t *) ((
char *) r + data);
737 return ngx_http_variable_headers_internal(r, v, data,
';');
745 return ngx_http_variable_headers_internal(r, v, data,
',');
766 for (i = 0; i < n; i++) {
768 if (h[i]->hash == 0) {
787 v->
len = (*h)->value.len;
788 v->
data = (*h)->value.data;
805 if (h[i]->hash == 0) {
815 *p++ = sep; *p++ =
' ';
828 sizeof(
"http_") - 1);
838 sizeof(
"sent_http_") - 1);
854 if (i >= part->
nelts) {
855 if (part->
next == NULL) {
864 if (header[i].hash == 0) {
868 for (n = 0; n + prefix < var->
len && n < header[
i].
key.
len; n++) {
871 if (ch >=
'A' && ch <=
'Z') {
874 }
else if (ch ==
'-') {
878 if (var->
data[n + prefix] != ch) {
883 if (n + prefix == var->
len && n == header[i].
key.
len) {
917 if (*p ==
CR || *p ==
LF) {
944 s.
len = name->
len - (
sizeof(
"cookie_") - 1);
945 s.
data = name->
data +
sizeof(
"cookie_") - 1;
974 len = name->
len - (
sizeof(
"arg_") - 1);
975 arg = name->
data +
sizeof(
"arg_") - 1;
992 #if (NGX_HAVE_TCP_INFO)
1002 len =
sizeof(
struct tcp_info);
1003 if (getsockopt(r->
connection->
fd, IPPROTO_TCP, TCP_INFO, &ti, &len) == -1) {
1009 if (v->
data == NULL) {
1015 value = ti.tcpi_rtt;
1019 value = ti.tcpi_rttvar;
1023 value = ti.tcpi_snd_cwnd;
1027 value = ti.tcpi_rcv_space;
1109 struct sockaddr_in *sin;
1110 #if (NGX_HAVE_INET6)
1111 struct sockaddr_in6 *sin6;
1116 #if (NGX_HAVE_INET6)
1120 v->
len =
sizeof(
struct in6_addr);
1124 v->
data = sin6->sin6_addr.s6_addr;
1132 v->
len =
sizeof(in_addr_t);
1136 v->
data = (u_char *) &sin->sin_addr;
1164 struct sockaddr_in *sin;
1165 #if (NGX_HAVE_INET6)
1166 struct sockaddr_in6 *sin6;
1175 if (v->
data == NULL) {
1181 #if (NGX_HAVE_INET6)
1184 port = ntohs(sin6->sin6_port);
1190 port = ntohs(sin->sin_port);
1194 if (port > 0 && port < 65536) {
1217 if (s.
data == NULL) {
1238 struct sockaddr_in *sin;
1239 #if (NGX_HAVE_INET6)
1240 struct sockaddr_in6 *sin6;
1253 if (v->
data == NULL) {
1259 #if (NGX_HAVE_INET6)
1262 port = ntohs(sin6->sin6_port);
1268 port = ntohs(sin->sin_port);
1272 if (port > 0 && port < 65536) {
1287 v->
len =
sizeof(
"https") - 1;
1291 v->
data = (u_char *)
"https";
1298 v->
len =
sizeof(
"http") - 1;
1302 v->
data = (u_char *)
"http";
1315 v->
len =
sizeof(
"on") - 1;
1319 v->
data = (u_char *)
"on";
1347 v->
data = (u_char *)
"?";
1400 #if (NGX_HAVE_MAX_PATH)
1417 path.
data[path.
len - 1] =
'\0';
1424 #if (NGX_HAVE_MAX_PATH)
1441 if (v->
data == NULL) {
1442 #if !(NGX_HAVE_MAX_PATH)
1455 #if !(NGX_HAVE_MAX_PATH)
1620 if (v->
data == NULL) {
1722 sizeof(
"sent_http_") - 1);
1744 sizeof(
"Last-Modified: Mon, 28 Sep 1970 06:00:00 GMT") - 1);
1772 len =
sizeof(
"upgrade") - 1;
1776 len =
sizeof(
"keep-alive") - 1;
1780 len =
sizeof(
"close") - 1;
1788 v->
data = (u_char *) p;
1832 v->
len =
sizeof(
"chunked") - 1;
1836 v->
data = (u_char *)
"chunked";
1855 v->
data = (u_char *)
"OK";
1864 v->
data = (u_char *)
"";
1891 if (cl->
next == NULL) {
1904 for ( ; cl; cl = cl->
next) {
1917 for ( ; cl; cl = cl->
next) {
2192 if (len && map->nregex) {
2195 ngx_http_map_regex_t *reg;
2199 for (i = 0; i < map->nregex; i++) {
2201 n = ngx_http_regex_exec(r, reg[i].regex, match);
2204 return reg[
i].value;
2242 ngx_http_regex_t *re;
2243 ngx_http_regex_variable_t *rv;
2258 re->regex = rc->
regex;
2270 rv =
ngx_palloc(rc->
pool, n *
sizeof(ngx_http_regex_variable_t));
2282 for (i = 0; i < n; i++) {
2283 rv[
i].capture = 2 * ((p[0] << 8) + p[1]);
2317 if (re->ncaptures) {
2320 if (r->captures == NULL) {
2322 if (r->captures == NULL) {
2344 for (i = 0; i < re->nvariables; i++) {
2346 n = re->variables[
i].capture;
2347 index = re->variables[
i].index;
2350 vv->
len = r->captures[n + 1] - r->captures[n];
2354 vv->
data = &s->
data[r->captures[n]];
2363 "http regex set $%V to \"%*s\"",
2369 r->ncaptures = rc * 2;
2370 r->captures_data = s->
data;
2402 for (cv = ngx_http_core_variables; cv->
name.
len; cv++) {
2419 "conflicting variable name \"%V\"", &v->
name);
2469 v[
i].
get_handler = ngx_http_variable_unknown_header_in;
2470 v[
i].
data = (uintptr_t) &v[i].name;
2476 v[
i].
get_handler = ngx_http_variable_unknown_header_out;
2477 v[
i].
data = (uintptr_t) &v[i].name;
2484 v[
i].
data = (uintptr_t) &v[i].name;
2492 v[
i].
data = (uintptr_t) &v[i].name;
2499 v[
i].
data = (uintptr_t) &v[i].name;
2506 "unknown \"%V\" variable", &v[i].
name);
2528 hash.
name =
"variables_hash";