Mercurial > hg > nginx-vendor-current
comparison src/http/ngx_http_variables.c @ 654:753f505670e0 NGINX_1_1_11
nginx 1.1.11
*) Feature: the "so_keepalive" parameter of the "listen" directive.
Thanks to Vsevolod Stakhov.
*) Feature: the "if_not_empty" parameter of the
"fastcgi/scgi/uwsgi_param" directives.
*) Feature: the $https variable.
*) Feature: the "proxy_redirect" directive supports variables in the
first parameter.
*) Feature: the "proxy_redirect" directive supports regular expressions.
*) Bugfix: the $sent_http_cache_control variable might contain a wrong
value if the "expires" directive was used.
Thanks to Yichun Zhang.
*) Bugfix: the "read_ahead" directive might not work combined with
"try_files" and "open_file_cache".
*) Bugfix: a segmentation fault might occur in a worker process if small
time was used in the "inactive" parameter of the "proxy_cache_path"
directive.
*) Bugfix: responses from cache might hang.
author | Igor Sysoev <http://sysoev.ru> |
---|---|
date | Mon, 12 Dec 2011 00:00:00 +0400 |
parents | 83b58b182b76 |
children | d0f7a625f27c |
comparison
equal
deleted
inserted
replaced
653:8c96af2112c1 | 654:753f505670e0 |
---|---|
45 static ngx_int_t ngx_http_variable_server_addr(ngx_http_request_t *r, | 45 static ngx_int_t ngx_http_variable_server_addr(ngx_http_request_t *r, |
46 ngx_http_variable_value_t *v, uintptr_t data); | 46 ngx_http_variable_value_t *v, uintptr_t data); |
47 static ngx_int_t ngx_http_variable_server_port(ngx_http_request_t *r, | 47 static ngx_int_t ngx_http_variable_server_port(ngx_http_request_t *r, |
48 ngx_http_variable_value_t *v, uintptr_t data); | 48 ngx_http_variable_value_t *v, uintptr_t data); |
49 static ngx_int_t ngx_http_variable_scheme(ngx_http_request_t *r, | 49 static ngx_int_t ngx_http_variable_scheme(ngx_http_request_t *r, |
50 ngx_http_variable_value_t *v, uintptr_t data); | |
51 static ngx_int_t ngx_http_variable_https(ngx_http_request_t *r, | |
50 ngx_http_variable_value_t *v, uintptr_t data); | 52 ngx_http_variable_value_t *v, uintptr_t data); |
51 static ngx_int_t ngx_http_variable_is_args(ngx_http_request_t *r, | 53 static ngx_int_t ngx_http_variable_is_args(ngx_http_request_t *r, |
52 ngx_http_variable_value_t *v, uintptr_t data); | 54 ngx_http_variable_value_t *v, uintptr_t data); |
53 static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r, | 55 static ngx_int_t ngx_http_variable_document_root(ngx_http_request_t *r, |
54 ngx_http_variable_value_t *v, uintptr_t data); | 56 ngx_http_variable_value_t *v, uintptr_t data); |
155 { ngx_string("server_protocol"), NULL, ngx_http_variable_request, | 157 { ngx_string("server_protocol"), NULL, ngx_http_variable_request, |
156 offsetof(ngx_http_request_t, http_protocol), 0, 0 }, | 158 offsetof(ngx_http_request_t, http_protocol), 0, 0 }, |
157 | 159 |
158 { ngx_string("scheme"), NULL, ngx_http_variable_scheme, 0, 0, 0 }, | 160 { ngx_string("scheme"), NULL, ngx_http_variable_scheme, 0, 0, 0 }, |
159 | 161 |
162 { ngx_string("https"), NULL, ngx_http_variable_https, 0, 0, 0 }, | |
163 | |
160 { ngx_string("request_uri"), NULL, ngx_http_variable_request, | 164 { ngx_string("request_uri"), NULL, ngx_http_variable_request, |
161 offsetof(ngx_http_request_t, unparsed_uri), 0, 0 }, | 165 offsetof(ngx_http_request_t, unparsed_uri), 0, 0 }, |
162 | 166 |
163 { ngx_string("uri"), NULL, ngx_http_variable_request, | 167 { ngx_string("uri"), NULL, ngx_http_variable_request, |
164 offsetof(ngx_http_request_t, uri), | 168 offsetof(ngx_http_request_t, uri), |
638 | 642 |
639 static ngx_int_t | 643 static ngx_int_t |
640 ngx_http_variable_headers(ngx_http_request_t *r, ngx_http_variable_value_t *v, | 644 ngx_http_variable_headers(ngx_http_request_t *r, ngx_http_variable_value_t *v, |
641 uintptr_t data) | 645 uintptr_t data) |
642 { | 646 { |
643 ssize_t len; | 647 size_t len; |
644 u_char *p; | 648 u_char *p, *end; |
645 ngx_uint_t i, n; | 649 ngx_uint_t i, n; |
646 ngx_array_t *a; | 650 ngx_array_t *a; |
647 ngx_table_elt_t **h; | 651 ngx_table_elt_t **h; |
648 | 652 |
649 a = (ngx_array_t *) ((char *) r + data); | 653 a = (ngx_array_t *) ((char *) r + data); |
650 | 654 |
651 n = a->nelts; | 655 n = a->nelts; |
652 | 656 h = a->elts; |
653 if (n == 0) { | 657 |
658 len = 0; | |
659 | |
660 for (i = 0; i < n; i++) { | |
661 | |
662 if (h[i]->hash == 0) { | |
663 continue; | |
664 } | |
665 | |
666 len += h[i]->value.len + sizeof("; ") - 1; | |
667 } | |
668 | |
669 if (len == 0) { | |
654 v->not_found = 1; | 670 v->not_found = 1; |
655 return NGX_OK; | 671 return NGX_OK; |
656 } | 672 } |
657 | 673 |
658 v->valid = 1; | 674 len -= sizeof("; ") - 1; |
659 v->no_cacheable = 0; | 675 |
660 v->not_found = 0; | 676 v->valid = 1; |
661 | 677 v->no_cacheable = 0; |
662 h = a->elts; | 678 v->not_found = 0; |
663 | 679 |
664 if (n == 1) { | 680 if (n == 1) { |
665 v->len = (*h)->value.len; | 681 v->len = (*h)->value.len; |
666 v->data = (*h)->value.data; | 682 v->data = (*h)->value.data; |
667 | 683 |
668 return NGX_OK; | 684 return NGX_OK; |
669 } | 685 } |
670 | 686 |
671 len = - (ssize_t) (sizeof("; ") - 1); | |
672 | |
673 for (i = 0; i < n; i++) { | |
674 len += h[i]->value.len + sizeof("; ") - 1; | |
675 } | |
676 | |
677 p = ngx_pnalloc(r->pool, len); | 687 p = ngx_pnalloc(r->pool, len); |
678 if (p == NULL) { | 688 if (p == NULL) { |
679 return NGX_ERROR; | 689 return NGX_ERROR; |
680 } | 690 } |
681 | 691 |
682 v->len = len; | 692 v->len = len; |
683 v->data = p; | 693 v->data = p; |
684 | 694 |
695 end = p + len; | |
696 | |
685 for (i = 0; /* void */ ; i++) { | 697 for (i = 0; /* void */ ; i++) { |
698 | |
699 if (h[i]->hash == 0) { | |
700 continue; | |
701 } | |
702 | |
686 p = ngx_copy(p, h[i]->value.data, h[i]->value.len); | 703 p = ngx_copy(p, h[i]->value.data, h[i]->value.len); |
687 | 704 |
688 if (i == n - 1) { | 705 if (p == end) { |
689 break; | 706 break; |
690 } | 707 } |
691 | 708 |
692 *p++ = ';'; *p++ = ' '; | 709 *p++ = ';'; *p++ = ' '; |
693 } | 710 } |
734 } | 751 } |
735 | 752 |
736 part = part->next; | 753 part = part->next; |
737 header = part->elts; | 754 header = part->elts; |
738 i = 0; | 755 i = 0; |
756 } | |
757 | |
758 if (header[i].hash == 0) { | |
759 continue; | |
739 } | 760 } |
740 | 761 |
741 for (n = 0; n + prefix < var->len && n < header[i].key.len; n++) { | 762 for (n = 0; n + prefix < var->len && n < header[i].key.len; n++) { |
742 ch = header[i].key.data[n]; | 763 ch = header[i].key.data[n]; |
743 | 764 |
1083 v->len = sizeof("http") - 1; | 1104 v->len = sizeof("http") - 1; |
1084 v->valid = 1; | 1105 v->valid = 1; |
1085 v->no_cacheable = 0; | 1106 v->no_cacheable = 0; |
1086 v->not_found = 0; | 1107 v->not_found = 0; |
1087 v->data = (u_char *) "http"; | 1108 v->data = (u_char *) "http"; |
1109 | |
1110 return NGX_OK; | |
1111 } | |
1112 | |
1113 | |
1114 static ngx_int_t | |
1115 ngx_http_variable_https(ngx_http_request_t *r, | |
1116 ngx_http_variable_value_t *v, uintptr_t data) | |
1117 { | |
1118 #if (NGX_HTTP_SSL) | |
1119 | |
1120 if (r->connection->ssl) { | |
1121 v->len = sizeof("on") - 1; | |
1122 v->valid = 1; | |
1123 v->no_cacheable = 0; | |
1124 v->not_found = 0; | |
1125 v->data = (u_char *) "on"; | |
1126 | |
1127 return NGX_OK; | |
1128 } | |
1129 | |
1130 #endif | |
1131 | |
1132 *v = ngx_http_variable_null_value; | |
1088 | 1133 |
1089 return NGX_OK; | 1134 return NGX_OK; |
1090 } | 1135 } |
1091 | 1136 |
1092 | 1137 |