comparison src/http/ngx_http_variables.c @ 644:ad25218fd14b NGINX_1_0_12

nginx 1.0.12 *) Feature: the "TLSv1.1" and "TLSv1.2" parameters of the "ssl_protocols" directive. *) Feature: the "if" SSI command supports captures in regular expressions. *) Bugfix: the "if" SSI command did not work inside the "block" command. *) Bugfix: in AIO error handling on FreeBSD. *) Bugfix: in the OpenSSL library initialization. *) Bugfix: the "worker_cpu_affinity" directive might not work. *) Bugfix: the "limit_conn_log_level" and "limit_req_log_level" directives might not work. *) Bugfix: the "read_ahead" directive might not work combined with "try_files" and "open_file_cache". *) Bugfix: the "proxy_cache_use_stale" directive with "error" parameter did not return answer from cache if there were no live upstreams. *) 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. *) Bugfix: in error handling while connecting to a backend. Thanks to Piotr Sikora. *) Bugfix: in the "epoll" event method. Thanks to Yichun Zhang. *) Bugfix: the $sent_http_cache_control variable might contain a wrong value if the "expires" directive was used. Thanks to Yichun Zhang. *) Bugfix: the "limit_rate" directive did not allow to use full throughput, even if limit value was very high. *) Bugfix: the "sendfile_max_chunk" directive did not work, if the "limit_rate" directive was used. *) Bugfix: nginx could not be built on Solaris; the bug had appeared in 1.0.11. *) Bugfix: in the ngx_http_scgi_module. *) Bugfix: in the ngx_http_mp4_module.
author Igor Sysoev <http://sysoev.ru>
date Mon, 06 Feb 2012 00:00:00 +0400
parents 83b58b182b76
children 09a689c5e494
comparison
equal deleted inserted replaced
643:d81e1c257a02 644:ad25218fd14b
1 1
2 /* 2 /*
3 * Copyright (C) Igor Sysoev 3 * Copyright (C) Igor Sysoev
4 * Copyright (C) Nginx, Inc.
4 */ 5 */
5 6
6 7
7 #include <ngx_config.h> 8 #include <ngx_config.h>
8 #include <ngx_core.h> 9 #include <ngx_core.h>
638 639
639 static ngx_int_t 640 static ngx_int_t
640 ngx_http_variable_headers(ngx_http_request_t *r, ngx_http_variable_value_t *v, 641 ngx_http_variable_headers(ngx_http_request_t *r, ngx_http_variable_value_t *v,
641 uintptr_t data) 642 uintptr_t data)
642 { 643 {
643 ssize_t len; 644 size_t len;
644 u_char *p; 645 u_char *p, *end;
645 ngx_uint_t i, n; 646 ngx_uint_t i, n;
646 ngx_array_t *a; 647 ngx_array_t *a;
647 ngx_table_elt_t **h; 648 ngx_table_elt_t **h;
648 649
649 a = (ngx_array_t *) ((char *) r + data); 650 a = (ngx_array_t *) ((char *) r + data);
650 651
651 n = a->nelts; 652 n = a->nelts;
652 653 h = a->elts;
653 if (n == 0) { 654
655 len = 0;
656
657 for (i = 0; i < n; i++) {
658
659 if (h[i]->hash == 0) {
660 continue;
661 }
662
663 len += h[i]->value.len + sizeof("; ") - 1;
664 }
665
666 if (len == 0) {
654 v->not_found = 1; 667 v->not_found = 1;
655 return NGX_OK; 668 return NGX_OK;
656 } 669 }
657 670
658 v->valid = 1; 671 len -= sizeof("; ") - 1;
659 v->no_cacheable = 0; 672
660 v->not_found = 0; 673 v->valid = 1;
661 674 v->no_cacheable = 0;
662 h = a->elts; 675 v->not_found = 0;
663 676
664 if (n == 1) { 677 if (n == 1) {
665 v->len = (*h)->value.len; 678 v->len = (*h)->value.len;
666 v->data = (*h)->value.data; 679 v->data = (*h)->value.data;
667 680
668 return NGX_OK; 681 return NGX_OK;
669 } 682 }
670 683
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); 684 p = ngx_pnalloc(r->pool, len);
678 if (p == NULL) { 685 if (p == NULL) {
679 return NGX_ERROR; 686 return NGX_ERROR;
680 } 687 }
681 688
682 v->len = len; 689 v->len = len;
683 v->data = p; 690 v->data = p;
684 691
692 end = p + len;
693
685 for (i = 0; /* void */ ; i++) { 694 for (i = 0; /* void */ ; i++) {
695
696 if (h[i]->hash == 0) {
697 continue;
698 }
699
686 p = ngx_copy(p, h[i]->value.data, h[i]->value.len); 700 p = ngx_copy(p, h[i]->value.data, h[i]->value.len);
687 701
688 if (i == n - 1) { 702 if (p == end) {
689 break; 703 break;
690 } 704 }
691 705
692 *p++ = ';'; *p++ = ' '; 706 *p++ = ';'; *p++ = ' ';
693 } 707 }
734 } 748 }
735 749
736 part = part->next; 750 part = part->next;
737 header = part->elts; 751 header = part->elts;
738 i = 0; 752 i = 0;
753 }
754
755 if (header[i].hash == 0) {
756 continue;
739 } 757 }
740 758
741 for (n = 0; n + prefix < var->len && n < header[i].key.len; n++) { 759 for (n = 0; n + prefix < var->len && n < header[i].key.len; n++) {
742 ch = header[i].key.data[n]; 760 ch = header[i].key.data[n];
743 761