comparison src/http/ngx_http_variables.c @ 328:26ff8d6b618d NGINX_0_5_34

nginx 0.5.34 *) Change: now the full request line instead of URI only is written to error_log. *) Feature: Cygwin compatibility. Thanks to Vladimir Kutakov. *) Feature: the "merge_slashes" directive. *) Feature: the "gzip_vary" directive. *) Feature: the "server_tokens" directive. *) Feature: the "access_log" directive may be used inside the "limit_except" block. *) Bugfix: if the $server_protocol was used in FastCGI parameters and a request line length was near to the "client_header_buffer_size" directive value, then nginx issued an alert "fastcgi: the request record is too big". *) Bugfix: if a plain text HTTP/0.9 version request was made to HTTPS server, then nginx returned usual response. *) Bugfix: URL double escaping in a redirect of the "msie_refresh" directive; bug appeared in 0.5.28. *) Bugfix: a segmentation fault might occur in worker process if subrequests were used. *) Bugfix: the big responses may be transferred truncated if SSL and gzip were used. *) Bugfix: compatibility with mget. *) Bugfix: nginx did not unescape URI in the "include" SSI command. *) Bugfix: the segmentation fault was occurred on start or while reconfiguration if variable was used in the "charset" or "source_charset" directives. *) Bugfix: nginx returned the 400 response on requests like "GET http://www.domain.com HTTP/1.0". Thanks to James Oakley. *) 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.
author Igor Sysoev <http://sysoev.ru>
date Thu, 13 Dec 2007 00:00:00 +0300
parents 1e9e2c5e7c14
children
comparison
equal deleted inserted replaced
327:cb962a94cd7b 328:26ff8d6b618d
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,
930 return NGX_ERROR; 930 return NGX_ERROR;
931 } 931 }
932 932
933 v->len = path.len; 933 v->len = path.len;
934 v->valid = 1; 934 v->valid = 1;
935 v->no_cachable = 0; 935 v->no_cacheable = 0;
936 v->not_found = 0; 936 v->not_found = 0;
937 v->data = path.data; 937 v->data = path.data;
938 } 938 }
939 939
940 return NGX_OK; 940 return NGX_OK;
954 954
955 /* ngx_http_map_uri_to_path() allocates memory for terminating '\0' */ 955 /* ngx_http_map_uri_to_path() allocates memory for terminating '\0' */
956 956
957 v->len = path.len - 1; 957 v->len = path.len - 1;
958 v->valid = 1; 958 v->valid = 1;
959 v->no_cachable = 0; 959 v->no_cacheable = 0;
960 v->not_found = 0; 960 v->not_found = 0;
961 v->data = path.data; 961 v->data = path.data;
962 962
963 return NGX_OK; 963 return NGX_OK;
964 } 964 }
969 ngx_http_variable_value_t *v, uintptr_t data) 969 ngx_http_variable_value_t *v, uintptr_t data)
970 { 970 {
971 if (r->main->method_name.data) { 971 if (r->main->method_name.data) {
972 v->len = r->main->method_name.len; 972 v->len = r->main->method_name.len;
973 v->valid = 1; 973 v->valid = 1;
974 v->no_cachable = 0; 974 v->no_cacheable = 0;
975 v->not_found = 0; 975 v->not_found = 0;
976 v->data = r->main->method_name.data; 976 v->data = r->main->method_name.data;
977 977
978 } else { 978 } else {
979 v->not_found = 1; 979 v->not_found = 1;
1000 return NGX_ERROR; 1000 return NGX_ERROR;
1001 } 1001 }
1002 1002
1003 v->len = r->headers_in.user.len; 1003 v->len = r->headers_in.user.len;
1004 v->valid = 1; 1004 v->valid = 1;
1005 v->no_cachable = 0; 1005 v->no_cacheable = 0;
1006 v->not_found = 0; 1006 v->not_found = 0;
1007 v->data = r->headers_in.user.data; 1007 v->data = r->headers_in.user.data;
1008 1008
1009 return NGX_OK; 1009 return NGX_OK;
1010 } 1010 }
1028 return NGX_ERROR; 1028 return NGX_ERROR;
1029 } 1029 }
1030 1030
1031 v->len = ngx_sprintf(p, "%O", sent) - p; 1031 v->len = ngx_sprintf(p, "%O", sent) - p;
1032 v->valid = 1; 1032 v->valid = 1;
1033 v->no_cachable = 0; 1033 v->no_cacheable = 0;
1034 v->not_found = 0; 1034 v->not_found = 0;
1035 v->data = p; 1035 v->data = p;
1036 1036
1037 return NGX_OK; 1037 return NGX_OK;
1038 } 1038 }
1043 ngx_http_variable_value_t *v, uintptr_t data) 1043 ngx_http_variable_value_t *v, uintptr_t data)
1044 { 1044 {
1045 if (r->headers_out.content_type.len) { 1045 if (r->headers_out.content_type.len) {
1046 v->len = r->headers_out.content_type.len; 1046 v->len = r->headers_out.content_type.len;
1047 v->valid = 1; 1047 v->valid = 1;
1048 v->no_cachable = 0; 1048 v->no_cacheable = 0;
1049 v->not_found = 0; 1049 v->not_found = 0;
1050 v->data = r->headers_out.content_type.data; 1050 v->data = r->headers_out.content_type.data;
1051 1051
1052 } else { 1052 } else {
1053 v->not_found = 1; 1053 v->not_found = 1;
1064 u_char *p; 1064 u_char *p;
1065 1065
1066 if (r->headers_out.content_length) { 1066 if (r->headers_out.content_length) {
1067 v->len = r->headers_out.content_length->value.len; 1067 v->len = r->headers_out.content_length->value.len;
1068 v->valid = 1; 1068 v->valid = 1;
1069 v->no_cachable = 0; 1069 v->no_cacheable = 0;
1070 v->not_found = 0; 1070 v->not_found = 0;
1071 v->data = r->headers_out.content_length->value.data; 1071 v->data = r->headers_out.content_length->value.data;
1072 1072
1073 return NGX_OK; 1073 return NGX_OK;
1074 } 1074 }
1079 return NGX_ERROR; 1079 return NGX_ERROR;
1080 } 1080 }
1081 1081
1082 v->len = ngx_sprintf(p, "%O", r->headers_out.content_length_n) - p; 1082 v->len = ngx_sprintf(p, "%O", r->headers_out.content_length_n) - p;
1083 v->valid = 1; 1083 v->valid = 1;
1084 v->no_cachable = 0; 1084 v->no_cacheable = 0;
1085 v->not_found = 0; 1085 v->not_found = 0;
1086 v->data = p; 1086 v->data = p;
1087 1087
1088 return NGX_OK; 1088 return NGX_OK;
1089 } 1089 }
1101 u_char *p; 1101 u_char *p;
1102 1102
1103 if (r->headers_out.last_modified) { 1103 if (r->headers_out.last_modified) {
1104 v->len = r->headers_out.last_modified->value.len; 1104 v->len = r->headers_out.last_modified->value.len;
1105 v->valid = 1; 1105 v->valid = 1;
1106 v->no_cachable = 0; 1106 v->no_cacheable = 0;
1107 v->not_found = 0; 1107 v->not_found = 0;
1108 v->data = r->headers_out.last_modified->value.data; 1108 v->data = r->headers_out.last_modified->value.data;
1109 1109
1110 return NGX_OK; 1110 return NGX_OK;
1111 } 1111 }
1117 return NGX_ERROR; 1117 return NGX_ERROR;
1118 } 1118 }
1119 1119
1120 v->len = ngx_http_time(p, r->headers_out.last_modified_time) - p; 1120 v->len = ngx_http_time(p, r->headers_out.last_modified_time) - p;
1121 v->valid = 1; 1121 v->valid = 1;
1122 v->no_cachable = 0; 1122 v->no_cacheable = 0;
1123 v->not_found = 0; 1123 v->not_found = 0;
1124 v->data = p; 1124 v->data = p;
1125 1125
1126 return NGX_OK; 1126 return NGX_OK;
1127 } 1127 }
1148 p = "close"; 1148 p = "close";
1149 } 1149 }
1150 1150
1151 v->len = len; 1151 v->len = len;
1152 v->valid = 1; 1152 v->valid = 1;
1153 v->no_cachable = 0; 1153 v->no_cacheable = 0;
1154 v->not_found = 0; 1154 v->not_found = 0;
1155 v->data = (u_char *) p; 1155 v->data = (u_char *) p;
1156 1156
1157 return NGX_OK; 1157 return NGX_OK;
1158 } 1158 }
1175 return NGX_ERROR; 1175 return NGX_ERROR;
1176 } 1176 }
1177 1177
1178 v->len = ngx_sprintf(p, "timeout=%T", clcf->keepalive_header) - p; 1178 v->len = ngx_sprintf(p, "timeout=%T", clcf->keepalive_header) - p;
1179 v->valid = 1; 1179 v->valid = 1;
1180 v->no_cachable = 0; 1180 v->no_cacheable = 0;
1181 v->not_found = 0; 1181 v->not_found = 0;
1182 v->data = p; 1182 v->data = p;
1183 1183
1184 return NGX_OK; 1184 return NGX_OK;
1185 } 1185 }
1196 ngx_http_variable_value_t *v, uintptr_t data) 1196 ngx_http_variable_value_t *v, uintptr_t data)
1197 { 1197 {
1198 if (r->chunked) { 1198 if (r->chunked) {
1199 v->len = sizeof("chunked") - 1; 1199 v->len = sizeof("chunked") - 1;
1200 v->valid = 1; 1200 v->valid = 1;
1201 v->no_cachable = 0; 1201 v->no_cacheable = 0;
1202 v->not_found = 0; 1202 v->not_found = 0;
1203 v->data = (u_char *) "chunked"; 1203 v->data = (u_char *) "chunked";
1204 1204
1205 } else { 1205 } else {
1206 v->not_found = 1; 1206 v->not_found = 1;
1215 ngx_http_variable_value_t *v, uintptr_t data) 1215 ngx_http_variable_value_t *v, uintptr_t data)
1216 { 1216 {
1217 if (r->request_complete) { 1217 if (r->request_complete) {
1218 v->len = 2; 1218 v->len = 2;
1219 v->valid = 1; 1219 v->valid = 1;
1220 v->no_cachable = 0; 1220 v->no_cacheable = 0;
1221 v->not_found = 0; 1221 v->not_found = 0;
1222 v->data = (u_char *) "OK"; 1222 v->data = (u_char *) "OK";
1223 1223
1224 return NGX_OK; 1224 return NGX_OK;
1225 } 1225 }
1226 1226
1227 v->len = 0; 1227 v->len = 0;
1228 v->valid = 1; 1228 v->valid = 1;
1229 v->no_cachable = 0; 1229 v->no_cacheable = 0;
1230 v->not_found = 0; 1230 v->not_found = 0;
1231 v->data = (u_char *) ""; 1231 v->data = (u_char *) "";
1232 1232
1233 return NGX_OK; 1233 return NGX_OK;
1234 } 1234 }
1244 return NGX_OK; 1244 return NGX_OK;
1245 } 1245 }
1246 1246
1247 v->len = r->request_body->temp_file->file.name.len; 1247 v->len = r->request_body->temp_file->file.name.len;
1248 v->valid = 1; 1248 v->valid = 1;
1249 v->no_cachable = 0; 1249 v->no_cacheable = 0;
1250 v->not_found = 0; 1250 v->not_found = 0;
1251 v->data = r->request_body->temp_file->file.name.data; 1251 v->data = r->request_body->temp_file->file.name.data;
1252 1252
1253 return NGX_OK; 1253 return NGX_OK;
1254 } 1254 }
1258 ngx_http_variable_nginx_version(ngx_http_request_t *r, 1258 ngx_http_variable_nginx_version(ngx_http_request_t *r,
1259 ngx_http_variable_value_t *v, uintptr_t data) 1259 ngx_http_variable_value_t *v, uintptr_t data)
1260 { 1260 {
1261 v->len = sizeof(NGINX_VERSION) - 1; 1261 v->len = sizeof(NGINX_VERSION) - 1;
1262 v->valid = 1; 1262 v->valid = 1;
1263 v->no_cachable = 0; 1263 v->no_cacheable = 0;
1264 v->not_found = 0; 1264 v->not_found = 0;
1265 v->data = (u_char *) NGINX_VERSION; 1265 v->data = (u_char *) NGINX_VERSION;
1266 1266
1267 return NGX_OK; 1267 return NGX_OK;
1268 } 1268 }
1366 } 1366 }
1367 1367
1368 if (ngx_strncmp(v[i].name.data, "upstream_http_", 14) == 0) { 1368 if (ngx_strncmp(v[i].name.data, "upstream_http_", 14) == 0) {
1369 v[i].get_handler = ngx_http_upstream_header_variable; 1369 v[i].get_handler = ngx_http_upstream_header_variable;
1370 v[i].data = (uintptr_t) &v[i].name; 1370 v[i].data = (uintptr_t) &v[i].name;
1371 v[i].flags = NGX_HTTP_VAR_NOCACHABLE; 1371 v[i].flags = NGX_HTTP_VAR_NOCACHEABLE;
1372 1372
1373 continue; 1373 continue;
1374 } 1374 }
1375 1375
1376 ngx_log_error(NGX_LOG_EMERG, cf->log, 0, 1376 ngx_log_error(NGX_LOG_EMERG, cf->log, 0,