Mercurial > hg > nginx-vendor-current
comparison src/http/ngx_http_variables.c @ 340:10cc350ed8a1 NGINX_0_6_14
nginx 0.6.14
*) Change: now by default the "echo" SSI command uses entity encoding.
*) Feature: the "encoding" parameter in the "echo" SSI command.
*) Feature: the "access_log" directive may be used inside the
"limit_except" block.
*) Bugfix: if all upstream servers were failed, then all servers had
got weight the was equal one until servers became alive; bug
appeared in 0.6.6.
*) Bugfix: a segmentation fault occurred in worker process if
$date_local and $date_gmt were used outside the
ngx_http_ssi_filter_module.
*) Bugfix: a segmentation fault might occur in worker process if debug
log was enabled.
Thanks to Andrei Nigmatulin.
*) Bugfix: ngx_http_memcached_module did not set
$upstream_response_time.
Thanks to Maxim Dounin.
*) Bugfix: a worker process may got caught in an endless loop, if the
memcached was used.
*) Bugfix: nginx supported low case only "close" and "keep-alive"
values in the "Connection" request header line; bug appeared in
0.6.11.
*) Bugfix: sub_filter did not work with empty substitution.
*) Bugfix: in sub_filter parsing.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 15 Oct 2007 00:00:00 +0400 |
parents | f7cd062ee035 |
children | 54fad6c4b555 |
comparison
equal
deleted
inserted
replaced
339:d19550b67059 | 340:10cc350ed8a1 |
---|---|
141 { ngx_string("request_uri"), NULL, ngx_http_variable_request, | 141 { ngx_string("request_uri"), NULL, ngx_http_variable_request, |
142 offsetof(ngx_http_request_t, unparsed_uri), 0, 0 }, | 142 offsetof(ngx_http_request_t, unparsed_uri), 0, 0 }, |
143 | 143 |
144 { ngx_string("uri"), NULL, ngx_http_variable_request, | 144 { ngx_string("uri"), NULL, ngx_http_variable_request, |
145 offsetof(ngx_http_request_t, uri), | 145 offsetof(ngx_http_request_t, uri), |
146 NGX_HTTP_VAR_NOCACHABLE, 0 }, | 146 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
147 | 147 |
148 { ngx_string("document_uri"), NULL, ngx_http_variable_request, | 148 { ngx_string("document_uri"), NULL, ngx_http_variable_request, |
149 offsetof(ngx_http_request_t, uri), | 149 offsetof(ngx_http_request_t, uri), |
150 NGX_HTTP_VAR_NOCACHABLE, 0 }, | 150 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
151 | 151 |
152 { ngx_string("request"), NULL, ngx_http_variable_request, | 152 { ngx_string("request"), NULL, ngx_http_variable_request, |
153 offsetof(ngx_http_request_t, request_line), 0, 0 }, | 153 offsetof(ngx_http_request_t, request_line), 0, 0 }, |
154 | 154 |
155 { ngx_string("document_root"), NULL, | 155 { ngx_string("document_root"), NULL, |
156 ngx_http_variable_document_root, 0, NGX_HTTP_VAR_NOCACHABLE, 0 }, | 156 ngx_http_variable_document_root, 0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
157 | 157 |
158 { ngx_string("query_string"), NULL, ngx_http_variable_request, | 158 { ngx_string("query_string"), NULL, ngx_http_variable_request, |
159 offsetof(ngx_http_request_t, args), | 159 offsetof(ngx_http_request_t, args), |
160 NGX_HTTP_VAR_NOCACHABLE, 0 }, | 160 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
161 | 161 |
162 { ngx_string("args"), | 162 { ngx_string("args"), |
163 ngx_http_variable_request_set, | 163 ngx_http_variable_request_set, |
164 ngx_http_variable_request, | 164 ngx_http_variable_request, |
165 offsetof(ngx_http_request_t, args), | 165 offsetof(ngx_http_request_t, args), |
166 NGX_HTTP_VAR_CHANGABLE|NGX_HTTP_VAR_NOCACHABLE, 0 }, | 166 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
167 | 167 |
168 { ngx_string("is_args"), NULL, ngx_http_variable_is_args, | 168 { ngx_string("is_args"), NULL, ngx_http_variable_is_args, |
169 0, NGX_HTTP_VAR_NOCACHABLE, 0 }, | 169 0, NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
170 | 170 |
171 { ngx_string("request_filename"), NULL, | 171 { ngx_string("request_filename"), NULL, |
172 ngx_http_variable_request_filename, 0, | 172 ngx_http_variable_request_filename, 0, |
173 NGX_HTTP_VAR_NOCACHABLE, 0 }, | 173 NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
174 | 174 |
175 { ngx_string("server_name"), NULL, ngx_http_variable_request, | 175 { ngx_string("server_name"), NULL, ngx_http_variable_request, |
176 offsetof(ngx_http_request_t, server_name), 0, 0 }, | 176 offsetof(ngx_http_request_t, server_name), 0, 0 }, |
177 | 177 |
178 { ngx_string("request_method"), NULL, | 178 { ngx_string("request_method"), NULL, |
213 offsetof(ngx_http_request_t, headers_out.cache_control), 0, 0 }, | 213 offsetof(ngx_http_request_t, headers_out.cache_control), 0, 0 }, |
214 | 214 |
215 { ngx_string("limit_rate"), ngx_http_variable_request_set_size, | 215 { ngx_string("limit_rate"), ngx_http_variable_request_set_size, |
216 ngx_http_variable_request, | 216 ngx_http_variable_request, |
217 offsetof(ngx_http_request_t, limit_rate), | 217 offsetof(ngx_http_request_t, limit_rate), |
218 NGX_HTTP_VAR_CHANGABLE|NGX_HTTP_VAR_NOCACHABLE, 0 }, | 218 NGX_HTTP_VAR_CHANGEABLE|NGX_HTTP_VAR_NOCACHEABLE, 0 }, |
219 | 219 |
220 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version, | 220 { ngx_string("nginx_version"), NULL, ngx_http_variable_nginx_version, |
221 0, 0, 0 }, | 221 0, 0, 0 }, |
222 | 222 |
223 { ngx_null_string, NULL, NULL, 0, 0, 0 } | 223 { ngx_null_string, NULL, NULL, 0, 0, 0 } |
249 continue; | 249 continue; |
250 } | 250 } |
251 | 251 |
252 v = key[i].value; | 252 v = key[i].value; |
253 | 253 |
254 if (!(v->flags & NGX_HTTP_VAR_CHANGABLE)) { | 254 if (!(v->flags & NGX_HTTP_VAR_CHANGEABLE)) { |
255 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, | 255 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, |
256 "the duplicate \"%V\" variable", name); | 256 "the duplicate \"%V\" variable", name); |
257 return NULL; | 257 return NULL; |
258 } | 258 } |
259 | 259 |
373 v = cmcf->variables.elts; | 373 v = cmcf->variables.elts; |
374 | 374 |
375 if (v[index].get_handler(r, &r->variables[index], v[index].data) | 375 if (v[index].get_handler(r, &r->variables[index], v[index].data) |
376 == NGX_OK) | 376 == NGX_OK) |
377 { | 377 { |
378 if (v[index].flags & NGX_HTTP_VAR_NOCACHABLE) { | 378 if (v[index].flags & NGX_HTTP_VAR_NOCACHEABLE) { |
379 r->variables[index].no_cachable = 1; | 379 r->variables[index].no_cacheable = 1; |
380 } | 380 } |
381 | 381 |
382 return &r->variables[index]; | 382 return &r->variables[index]; |
383 } | 383 } |
384 | 384 |
395 ngx_http_variable_value_t *v; | 395 ngx_http_variable_value_t *v; |
396 | 396 |
397 v = &r->variables[index]; | 397 v = &r->variables[index]; |
398 | 398 |
399 if (v->valid) { | 399 if (v->valid) { |
400 if (!v->no_cachable) { | 400 if (!v->no_cacheable) { |
401 return v; | 401 return v; |
402 } | 402 } |
403 | 403 |
404 v->valid = 0; | 404 v->valid = 0; |
405 v->not_found = 0; | 405 v->not_found = 0; |
495 s = (ngx_str_t *) ((char *) r + data); | 495 s = (ngx_str_t *) ((char *) r + data); |
496 | 496 |
497 if (s->data) { | 497 if (s->data) { |
498 v->len = s->len; | 498 v->len = s->len; |
499 v->valid = 1; | 499 v->valid = 1; |
500 v->no_cachable = 0; | 500 v->no_cacheable = 0; |
501 v->not_found = 0; | 501 v->not_found = 0; |
502 v->data = s->data; | 502 v->data = s->data; |
503 | 503 |
504 } else { | 504 } else { |
505 v->not_found = 1; | 505 v->not_found = 1; |
557 h = *(ngx_table_elt_t **) ((char *) r + data); | 557 h = *(ngx_table_elt_t **) ((char *) r + data); |
558 | 558 |
559 if (h) { | 559 if (h) { |
560 v->len = h->value.len; | 560 v->len = h->value.len; |
561 v->valid = 1; | 561 v->valid = 1; |
562 v->no_cachable = 0; | 562 v->no_cacheable = 0; |
563 v->not_found = 0; | 563 v->not_found = 0; |
564 v->data = h->value.data; | 564 v->data = h->value.data; |
565 | 565 |
566 } else { | 566 } else { |
567 v->not_found = 1; | 567 v->not_found = 1; |
589 v->not_found = 1; | 589 v->not_found = 1; |
590 return NGX_OK; | 590 return NGX_OK; |
591 } | 591 } |
592 | 592 |
593 v->valid = 1; | 593 v->valid = 1; |
594 v->no_cachable = 0; | 594 v->no_cacheable = 0; |
595 v->not_found = 0; | 595 v->not_found = 0; |
596 | 596 |
597 h = a->elts; | 597 h = a->elts; |
598 | 598 |
599 if (n == 1) { | 599 if (n == 1) { |
689 } | 689 } |
690 | 690 |
691 if (n + prefix == var->len && n == header[i].key.len) { | 691 if (n + prefix == var->len && n == header[i].key.len) { |
692 v->len = header[i].value.len; | 692 v->len = header[i].value.len; |
693 v->valid = 1; | 693 v->valid = 1; |
694 v->no_cachable = 0; | 694 v->no_cacheable = 0; |
695 v->not_found = 0; | 695 v->not_found = 0; |
696 v->data = header[i].value.data; | 696 v->data = header[i].value.data; |
697 | 697 |
698 return NGX_OK; | 698 return NGX_OK; |
699 } | 699 } |
728 v->not_found = 1; | 728 v->not_found = 1; |
729 return NGX_OK; | 729 return NGX_OK; |
730 } | 730 } |
731 | 731 |
732 v->valid = 1; | 732 v->valid = 1; |
733 v->no_cachable = 0; | 733 v->no_cacheable = 0; |
734 v->not_found = 0; | 734 v->not_found = 0; |
735 | 735 |
736 return NGX_OK; | 736 return NGX_OK; |
737 } | 737 } |
738 | 738 |
747 | 747 |
748 sin = (struct sockaddr_in *) r->connection->sockaddr; | 748 sin = (struct sockaddr_in *) r->connection->sockaddr; |
749 | 749 |
750 v->len = sizeof(in_addr_t); | 750 v->len = sizeof(in_addr_t); |
751 v->valid = 1; | 751 v->valid = 1; |
752 v->no_cachable = 0; | 752 v->no_cacheable = 0; |
753 v->not_found = 0; | 753 v->not_found = 0; |
754 v->data = (u_char *) &sin->sin_addr.s_addr; | 754 v->data = (u_char *) &sin->sin_addr.s_addr; |
755 | 755 |
756 return NGX_OK; | 756 return NGX_OK; |
757 } | 757 } |
761 ngx_http_variable_remote_addr(ngx_http_request_t *r, | 761 ngx_http_variable_remote_addr(ngx_http_request_t *r, |
762 ngx_http_variable_value_t *v, uintptr_t data) | 762 ngx_http_variable_value_t *v, uintptr_t data) |
763 { | 763 { |
764 v->len = r->connection->addr_text.len; | 764 v->len = r->connection->addr_text.len; |
765 v->valid = 1; | 765 v->valid = 1; |
766 v->no_cachable = 0; | 766 v->no_cacheable = 0; |
767 v->not_found = 0; | 767 v->not_found = 0; |
768 v->data = r->connection->addr_text.data; | 768 v->data = r->connection->addr_text.data; |
769 | 769 |
770 return NGX_OK; | 770 return NGX_OK; |
771 } | 771 } |
778 ngx_uint_t port; | 778 ngx_uint_t port; |
779 struct sockaddr_in *sin; | 779 struct sockaddr_in *sin; |
780 | 780 |
781 v->len = 0; | 781 v->len = 0; |
782 v->valid = 1; | 782 v->valid = 1; |
783 v->no_cachable = 0; | 783 v->no_cacheable = 0; |
784 v->not_found = 0; | 784 v->not_found = 0; |
785 | 785 |
786 v->data = ngx_palloc(r->pool, sizeof("65535") - 1); | 786 v->data = ngx_palloc(r->pool, sizeof("65535") - 1); |
787 if (v->data == NULL) { | 787 if (v->data == NULL) { |
788 return NGX_ERROR; | 788 return NGX_ERROR; |
830 } | 830 } |
831 | 831 |
832 v->len = ngx_inet_ntop(c->listening->family, &r->in_addr, | 832 v->len = ngx_inet_ntop(c->listening->family, &r->in_addr, |
833 v->data, INET_ADDRSTRLEN); | 833 v->data, INET_ADDRSTRLEN); |
834 v->valid = 1; | 834 v->valid = 1; |
835 v->no_cachable = 0; | 835 v->no_cacheable = 0; |
836 v->not_found = 0; | 836 v->not_found = 0; |
837 | 837 |
838 return NGX_OK; | 838 return NGX_OK; |
839 } | 839 } |
840 | 840 |
843 ngx_http_variable_server_port(ngx_http_request_t *r, | 843 ngx_http_variable_server_port(ngx_http_request_t *r, |
844 ngx_http_variable_value_t *v, uintptr_t data) | 844 ngx_http_variable_value_t *v, uintptr_t data) |
845 { | 845 { |
846 v->len = r->port_text->len - 1; | 846 v->len = r->port_text->len - 1; |
847 v->valid = 1; | 847 v->valid = 1; |
848 v->no_cachable = 0; | 848 v->no_cacheable = 0; |
849 v->not_found = 0; | 849 v->not_found = 0; |
850 v->data = r->port_text->data + 1; | 850 v->data = r->port_text->data + 1; |
851 | 851 |
852 return NGX_OK; | 852 return NGX_OK; |
853 } | 853 } |
860 #if (NGX_HTTP_SSL) | 860 #if (NGX_HTTP_SSL) |
861 | 861 |
862 if (r->connection->ssl) { | 862 if (r->connection->ssl) { |
863 v->len = sizeof("https") - 1; | 863 v->len = sizeof("https") - 1; |
864 v->valid = 1; | 864 v->valid = 1; |
865 v->no_cachable = 0; | 865 v->no_cacheable = 0; |
866 v->not_found = 0; | 866 v->not_found = 0; |
867 v->data = (u_char *) "https"; | 867 v->data = (u_char *) "https"; |
868 | 868 |
869 return NGX_OK; | 869 return NGX_OK; |
870 } | 870 } |
871 | 871 |
872 #endif | 872 #endif |
873 | 873 |
874 v->len = sizeof("http") - 1; | 874 v->len = sizeof("http") - 1; |
875 v->valid = 1; | 875 v->valid = 1; |
876 v->no_cachable = 0; | 876 v->no_cacheable = 0; |
877 v->not_found = 0; | 877 v->not_found = 0; |
878 v->data = (u_char *) "http"; | 878 v->data = (u_char *) "http"; |
879 | 879 |
880 return NGX_OK; | 880 return NGX_OK; |
881 } | 881 } |
884 static ngx_int_t | 884 static ngx_int_t |
885 ngx_http_variable_is_args(ngx_http_request_t *r, | 885 ngx_http_variable_is_args(ngx_http_request_t *r, |
886 ngx_http_variable_value_t *v, uintptr_t data) | 886 ngx_http_variable_value_t *v, uintptr_t data) |
887 { | 887 { |
888 v->valid = 1; | 888 v->valid = 1; |
889 v->no_cachable = 0; | 889 v->no_cacheable = 0; |
890 v->not_found = 0; | 890 v->not_found = 0; |
891 | 891 |
892 if (r->args.len == 0) { | 892 if (r->args.len == 0) { |
893 v->len = 0; | 893 v->len = 0; |
894 v->data = NULL; | 894 v->data = NULL; |
912 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); | 912 clcf = ngx_http_get_module_loc_conf(r, ngx_http_core_module); |
913 | 913 |
914 if (clcf->root_lengths == NULL) { | 914 if (clcf->root_lengths == NULL) { |
915 v->len = clcf->root.len; | 915 v->len = clcf->root.len; |
916 v->valid = 1; | 916 v->valid = 1; |
917 v->no_cachable = 0; | 917 v->no_cacheable = 0; |
918 v->not_found = 0; | 918 v->not_found = 0; |
919 v->data = clcf->root.data; | 919 v->data = clcf->root.data; |
920 | 920 |
921 } else { | 921 } else { |
922 if (ngx_http_script_run(r, &path, clcf->root_lengths->elts, 0, | 922 if (ngx_http_script_run(r, &path, clcf->root_lengths->elts, 0, |
932 return NGX_ERROR; | 932 return NGX_ERROR; |
933 } | 933 } |
934 | 934 |
935 v->len = path.len; | 935 v->len = path.len; |
936 v->valid = 1; | 936 v->valid = 1; |
937 v->no_cachable = 0; | 937 v->no_cacheable = 0; |
938 v->not_found = 0; | 938 v->not_found = 0; |
939 v->data = path.data; | 939 v->data = path.data; |
940 } | 940 } |
941 | 941 |
942 return NGX_OK; | 942 return NGX_OK; |
956 | 956 |
957 /* ngx_http_map_uri_to_path() allocates memory for terminating '\0' */ | 957 /* ngx_http_map_uri_to_path() allocates memory for terminating '\0' */ |
958 | 958 |
959 v->len = path.len - 1; | 959 v->len = path.len - 1; |
960 v->valid = 1; | 960 v->valid = 1; |
961 v->no_cachable = 0; | 961 v->no_cacheable = 0; |
962 v->not_found = 0; | 962 v->not_found = 0; |
963 v->data = path.data; | 963 v->data = path.data; |
964 | 964 |
965 return NGX_OK; | 965 return NGX_OK; |
966 } | 966 } |
971 ngx_http_variable_value_t *v, uintptr_t data) | 971 ngx_http_variable_value_t *v, uintptr_t data) |
972 { | 972 { |
973 if (r->main->method_name.data) { | 973 if (r->main->method_name.data) { |
974 v->len = r->main->method_name.len; | 974 v->len = r->main->method_name.len; |
975 v->valid = 1; | 975 v->valid = 1; |
976 v->no_cachable = 0; | 976 v->no_cacheable = 0; |
977 v->not_found = 0; | 977 v->not_found = 0; |
978 v->data = r->main->method_name.data; | 978 v->data = r->main->method_name.data; |
979 | 979 |
980 } else { | 980 } else { |
981 v->not_found = 1; | 981 v->not_found = 1; |
1002 return NGX_ERROR; | 1002 return NGX_ERROR; |
1003 } | 1003 } |
1004 | 1004 |
1005 v->len = r->headers_in.user.len; | 1005 v->len = r->headers_in.user.len; |
1006 v->valid = 1; | 1006 v->valid = 1; |
1007 v->no_cachable = 0; | 1007 v->no_cacheable = 0; |
1008 v->not_found = 0; | 1008 v->not_found = 0; |
1009 v->data = r->headers_in.user.data; | 1009 v->data = r->headers_in.user.data; |
1010 | 1010 |
1011 return NGX_OK; | 1011 return NGX_OK; |
1012 } | 1012 } |
1030 return NGX_ERROR; | 1030 return NGX_ERROR; |
1031 } | 1031 } |
1032 | 1032 |
1033 v->len = ngx_sprintf(p, "%O", sent) - p; | 1033 v->len = ngx_sprintf(p, "%O", sent) - p; |
1034 v->valid = 1; | 1034 v->valid = 1; |
1035 v->no_cachable = 0; | 1035 v->no_cacheable = 0; |
1036 v->not_found = 0; | 1036 v->not_found = 0; |
1037 v->data = p; | 1037 v->data = p; |
1038 | 1038 |
1039 return NGX_OK; | 1039 return NGX_OK; |
1040 } | 1040 } |
1045 ngx_http_variable_value_t *v, uintptr_t data) | 1045 ngx_http_variable_value_t *v, uintptr_t data) |
1046 { | 1046 { |
1047 if (r->headers_out.content_type.len) { | 1047 if (r->headers_out.content_type.len) { |
1048 v->len = r->headers_out.content_type.len; | 1048 v->len = r->headers_out.content_type.len; |
1049 v->valid = 1; | 1049 v->valid = 1; |
1050 v->no_cachable = 0; | 1050 v->no_cacheable = 0; |
1051 v->not_found = 0; | 1051 v->not_found = 0; |
1052 v->data = r->headers_out.content_type.data; | 1052 v->data = r->headers_out.content_type.data; |
1053 | 1053 |
1054 } else { | 1054 } else { |
1055 v->not_found = 1; | 1055 v->not_found = 1; |
1066 u_char *p; | 1066 u_char *p; |
1067 | 1067 |
1068 if (r->headers_out.content_length) { | 1068 if (r->headers_out.content_length) { |
1069 v->len = r->headers_out.content_length->value.len; | 1069 v->len = r->headers_out.content_length->value.len; |
1070 v->valid = 1; | 1070 v->valid = 1; |
1071 v->no_cachable = 0; | 1071 v->no_cacheable = 0; |
1072 v->not_found = 0; | 1072 v->not_found = 0; |
1073 v->data = r->headers_out.content_length->value.data; | 1073 v->data = r->headers_out.content_length->value.data; |
1074 | 1074 |
1075 return NGX_OK; | 1075 return NGX_OK; |
1076 } | 1076 } |
1081 return NGX_ERROR; | 1081 return NGX_ERROR; |
1082 } | 1082 } |
1083 | 1083 |
1084 v->len = ngx_sprintf(p, "%O", r->headers_out.content_length_n) - p; | 1084 v->len = ngx_sprintf(p, "%O", r->headers_out.content_length_n) - p; |
1085 v->valid = 1; | 1085 v->valid = 1; |
1086 v->no_cachable = 0; | 1086 v->no_cacheable = 0; |
1087 v->not_found = 0; | 1087 v->not_found = 0; |
1088 v->data = p; | 1088 v->data = p; |
1089 | 1089 |
1090 return NGX_OK; | 1090 return NGX_OK; |
1091 } | 1091 } |
1103 u_char *p; | 1103 u_char *p; |
1104 | 1104 |
1105 if (r->headers_out.last_modified) { | 1105 if (r->headers_out.last_modified) { |
1106 v->len = r->headers_out.last_modified->value.len; | 1106 v->len = r->headers_out.last_modified->value.len; |
1107 v->valid = 1; | 1107 v->valid = 1; |
1108 v->no_cachable = 0; | 1108 v->no_cacheable = 0; |
1109 v->not_found = 0; | 1109 v->not_found = 0; |
1110 v->data = r->headers_out.last_modified->value.data; | 1110 v->data = r->headers_out.last_modified->value.data; |
1111 | 1111 |
1112 return NGX_OK; | 1112 return NGX_OK; |
1113 } | 1113 } |
1119 return NGX_ERROR; | 1119 return NGX_ERROR; |
1120 } | 1120 } |
1121 | 1121 |
1122 v->len = ngx_http_time(p, r->headers_out.last_modified_time) - p; | 1122 v->len = ngx_http_time(p, r->headers_out.last_modified_time) - p; |
1123 v->valid = 1; | 1123 v->valid = 1; |
1124 v->no_cachable = 0; | 1124 v->no_cacheable = 0; |
1125 v->not_found = 0; | 1125 v->not_found = 0; |
1126 v->data = p; | 1126 v->data = p; |
1127 | 1127 |
1128 return NGX_OK; | 1128 return NGX_OK; |
1129 } | 1129 } |
1150 p = "close"; | 1150 p = "close"; |
1151 } | 1151 } |
1152 | 1152 |
1153 v->len = len; | 1153 v->len = len; |
1154 v->valid = 1; | 1154 v->valid = 1; |
1155 v->no_cachable = 0; | 1155 v->no_cacheable = 0; |
1156 v->not_found = 0; | 1156 v->not_found = 0; |
1157 v->data = (u_char *) p; | 1157 v->data = (u_char *) p; |
1158 | 1158 |
1159 return NGX_OK; | 1159 return NGX_OK; |
1160 } | 1160 } |
1177 return NGX_ERROR; | 1177 return NGX_ERROR; |
1178 } | 1178 } |
1179 | 1179 |
1180 v->len = ngx_sprintf(p, "timeout=%T", clcf->keepalive_header) - p; | 1180 v->len = ngx_sprintf(p, "timeout=%T", clcf->keepalive_header) - p; |
1181 v->valid = 1; | 1181 v->valid = 1; |
1182 v->no_cachable = 0; | 1182 v->no_cacheable = 0; |
1183 v->not_found = 0; | 1183 v->not_found = 0; |
1184 v->data = p; | 1184 v->data = p; |
1185 | 1185 |
1186 return NGX_OK; | 1186 return NGX_OK; |
1187 } | 1187 } |
1198 ngx_http_variable_value_t *v, uintptr_t data) | 1198 ngx_http_variable_value_t *v, uintptr_t data) |
1199 { | 1199 { |
1200 if (r->chunked) { | 1200 if (r->chunked) { |
1201 v->len = sizeof("chunked") - 1; | 1201 v->len = sizeof("chunked") - 1; |
1202 v->valid = 1; | 1202 v->valid = 1; |
1203 v->no_cachable = 0; | 1203 v->no_cacheable = 0; |
1204 v->not_found = 0; | 1204 v->not_found = 0; |
1205 v->data = (u_char *) "chunked"; | 1205 v->data = (u_char *) "chunked"; |
1206 | 1206 |
1207 } else { | 1207 } else { |
1208 v->not_found = 1; | 1208 v->not_found = 1; |
1217 ngx_http_variable_value_t *v, uintptr_t data) | 1217 ngx_http_variable_value_t *v, uintptr_t data) |
1218 { | 1218 { |
1219 if (r->request_complete) { | 1219 if (r->request_complete) { |
1220 v->len = 2; | 1220 v->len = 2; |
1221 v->valid = 1; | 1221 v->valid = 1; |
1222 v->no_cachable = 0; | 1222 v->no_cacheable = 0; |
1223 v->not_found = 0; | 1223 v->not_found = 0; |
1224 v->data = (u_char *) "OK"; | 1224 v->data = (u_char *) "OK"; |
1225 | 1225 |
1226 return NGX_OK; | 1226 return NGX_OK; |
1227 } | 1227 } |
1228 | 1228 |
1229 v->len = 0; | 1229 v->len = 0; |
1230 v->valid = 1; | 1230 v->valid = 1; |
1231 v->no_cachable = 0; | 1231 v->no_cacheable = 0; |
1232 v->not_found = 0; | 1232 v->not_found = 0; |
1233 v->data = (u_char *) ""; | 1233 v->data = (u_char *) ""; |
1234 | 1234 |
1235 return NGX_OK; | 1235 return NGX_OK; |
1236 } | 1236 } |
1246 return NGX_OK; | 1246 return NGX_OK; |
1247 } | 1247 } |
1248 | 1248 |
1249 v->len = r->request_body->temp_file->file.name.len; | 1249 v->len = r->request_body->temp_file->file.name.len; |
1250 v->valid = 1; | 1250 v->valid = 1; |
1251 v->no_cachable = 0; | 1251 v->no_cacheable = 0; |
1252 v->not_found = 0; | 1252 v->not_found = 0; |
1253 v->data = r->request_body->temp_file->file.name.data; | 1253 v->data = r->request_body->temp_file->file.name.data; |
1254 | 1254 |
1255 return NGX_OK; | 1255 return NGX_OK; |
1256 } | 1256 } |
1260 ngx_http_variable_nginx_version(ngx_http_request_t *r, | 1260 ngx_http_variable_nginx_version(ngx_http_request_t *r, |
1261 ngx_http_variable_value_t *v, uintptr_t data) | 1261 ngx_http_variable_value_t *v, uintptr_t data) |
1262 { | 1262 { |
1263 v->len = sizeof(NGINX_VERSION) - 1; | 1263 v->len = sizeof(NGINX_VERSION) - 1; |
1264 v->valid = 1; | 1264 v->valid = 1; |
1265 v->no_cachable = 0; | 1265 v->no_cacheable = 0; |
1266 v->not_found = 0; | 1266 v->not_found = 0; |
1267 v->data = (u_char *) NGINX_VERSION; | 1267 v->data = (u_char *) NGINX_VERSION; |
1268 | 1268 |
1269 return NGX_OK; | 1269 return NGX_OK; |
1270 } | 1270 } |
1368 } | 1368 } |
1369 | 1369 |
1370 if (ngx_strncmp(v[i].name.data, "upstream_http_", 14) == 0) { | 1370 if (ngx_strncmp(v[i].name.data, "upstream_http_", 14) == 0) { |
1371 v[i].get_handler = ngx_http_upstream_header_variable; | 1371 v[i].get_handler = ngx_http_upstream_header_variable; |
1372 v[i].data = (uintptr_t) &v[i].name; | 1372 v[i].data = (uintptr_t) &v[i].name; |
1373 v[i].flags = NGX_HTTP_VAR_NOCACHABLE; | 1373 v[i].flags = NGX_HTTP_VAR_NOCACHEABLE; |
1374 | 1374 |
1375 continue; | 1375 continue; |
1376 } | 1376 } |
1377 | 1377 |
1378 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, | 1378 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, |