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