|
9 | 9 | * Contains elements adapted from ngx_lua: |
10 | 10 | * Copyright (C) 2009-2015, by Xiaozhe Wang (chaoslawful) [email protected]. |
11 | 11 | * Copyright (C) 2009-2015, by Yichun "agentzh" Zhang (章亦春) [email protected], CloudFlare Inc. |
| 12 | + * Contains elements adapted from ngx_headers_more: |
| 13 | + * Copyright (c) 2009-2017, Yichun "agentzh" Zhang (章亦春) [email protected], OpenResty Inc. |
| 14 | + * Copyright (c) 2010-2013, Bernd Dorn. |
12 | 15 | * |
13 | 16 | * Distributed under 2-clause BSD license, see LICENSE file. |
14 | 17 | */ |
@@ -760,6 +763,9 @@ ngx_http_set_header_helper(ngx_http_request_t *r, ngx_http_shib_request_header_v |
760 | 763 |
|
761 | 764 | h->key = hv->key; |
762 | 765 | h->value = *value; |
| 766 | +#if defined(nginx_version) && nginx_version >= 1023000 |
| 767 | + h->next = NULL; |
| 768 | +#endif |
763 | 769 |
|
764 | 770 | h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); |
765 | 771 | if (h->lowcase_key == NULL) { |
@@ -840,6 +846,46 @@ static ngx_int_t |
840 | 846 | ngx_http_set_builtin_multi_header(ngx_http_request_t *r, |
841 | 847 | ngx_http_shib_request_header_val_t *hv, ngx_str_t *value) |
842 | 848 | { |
| 849 | +#if defined(nginx_version) && nginx_version >= 1023000 |
| 850 | + ngx_table_elt_t **headers, *h, *ho, **ph; |
| 851 | + |
| 852 | + headers = (ngx_table_elt_t **) ((char *) &r->headers_out + hv->offset); |
| 853 | + |
| 854 | + if (*headers) { |
| 855 | + for (h = (*headers)->next; h; h = h->next) { |
| 856 | + h->hash = 0; |
| 857 | + h->value.len = 0; |
| 858 | + } |
| 859 | + |
| 860 | + h = *headers; |
| 861 | + |
| 862 | + h->value = *value; |
| 863 | + |
| 864 | + if (value->len == 0) { |
| 865 | + h->hash = 0; |
| 866 | + |
| 867 | + } else { |
| 868 | + h->hash = hv->hash; |
| 869 | + } |
| 870 | + |
| 871 | + return NGX_OK; |
| 872 | + } |
| 873 | + |
| 874 | + for (ph = headers; *ph; ph = &(*ph)->next) { /* void */ } |
| 875 | + |
| 876 | + ho = ngx_list_push(&r->headers_out.headers); |
| 877 | + if (ho == NULL) { |
| 878 | + return NGX_ERROR; |
| 879 | + } |
| 880 | + |
| 881 | + ho->value = *value; |
| 882 | + ho->hash = hv->hash; |
| 883 | + ngx_str_set(&ho->key, "Cache-Control"); |
| 884 | + ho->next = NULL; |
| 885 | + *ph = ho; |
| 886 | + |
| 887 | + return NGX_OK; |
| 888 | +#else |
843 | 889 | ngx_array_t *pa; |
844 | 890 | ngx_table_elt_t *ho, **ph; |
845 | 891 | ngx_uint_t i; |
@@ -898,6 +944,7 @@ ngx_http_set_builtin_multi_header(ngx_http_request_t *r, |
898 | 944 | *ph = ho; |
899 | 945 |
|
900 | 946 | return NGX_OK; |
| 947 | +#endif |
901 | 948 | } |
902 | 949 |
|
903 | 950 |
|
|
0 commit comments