Skip to content

Commit be12df5

Browse files
authored
Merge pull request #50 from heikojansen/compat_nginx_1-23-0
Fix compatibility with nginx 1.23.0+
2 parents 74f9c37 + 99d72dc commit be12df5

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

ngx_http_shibboleth_module.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
* Contains elements adapted from ngx_lua:
1010
* Copyright (C) 2009-2015, by Xiaozhe Wang (chaoslawful) chaoslawful@gmail.com.
1111
* 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.
1215
*
1316
* Distributed under 2-clause BSD license, see LICENSE file.
1417
*/
@@ -760,6 +763,9 @@ ngx_http_set_header_helper(ngx_http_request_t *r, ngx_http_shib_request_header_v
760763

761764
h->key = hv->key;
762765
h->value = *value;
766+
#if defined(nginx_version) && nginx_version >= 1023000
767+
h->next = NULL;
768+
#endif
763769

764770
h->lowcase_key = ngx_pnalloc(r->pool, h->key.len);
765771
if (h->lowcase_key == NULL) {
@@ -840,6 +846,46 @@ static ngx_int_t
840846
ngx_http_set_builtin_multi_header(ngx_http_request_t *r,
841847
ngx_http_shib_request_header_val_t *hv, ngx_str_t *value)
842848
{
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
843889
ngx_array_t *pa;
844890
ngx_table_elt_t *ho, **ph;
845891
ngx_uint_t i;
@@ -898,6 +944,7 @@ ngx_http_set_builtin_multi_header(ngx_http_request_t *r,
898944
*ph = ho;
899945

900946
return NGX_OK;
947+
#endif
901948
}
902949

903950

0 commit comments

Comments
 (0)