Skip to content
Snippets Groups Projects
Unverified Commit be12df59 authored by David Beitey's avatar David Beitey Committed by GitHub
Browse files

Merge pull request #50 from heikojansen/compat_nginx_1-23-0

Fix compatibility with nginx 1.23.0+
parents 74f9c373 99d72dc8
No related branches found
No related tags found
No related merge requests found
...@@ -9,6 +9,9 @@ ...@@ -9,6 +9,9 @@
* Contains elements adapted from ngx_lua: * Contains elements adapted from ngx_lua:
* Copyright (C) 2009-2015, by Xiaozhe Wang (chaoslawful) chaoslawful@gmail.com. * Copyright (C) 2009-2015, by Xiaozhe Wang (chaoslawful) chaoslawful@gmail.com.
* Copyright (C) 2009-2015, by Yichun "agentzh" Zhang (章亦春) agentzh@gmail.com, CloudFlare Inc. * Copyright (C) 2009-2015, by Yichun "agentzh" Zhang (章亦春) agentzh@gmail.com, CloudFlare Inc.
* Contains elements adapted from ngx_headers_more:
* Copyright (c) 2009-2017, Yichun "agentzh" Zhang (章亦春) agentzh@gmail.com, OpenResty Inc.
* Copyright (c) 2010-2013, Bernd Dorn.
* *
* Distributed under 2-clause BSD license, see LICENSE file. * Distributed under 2-clause BSD license, see LICENSE file.
*/ */
...@@ -760,6 +763,9 @@ ngx_http_set_header_helper(ngx_http_request_t *r, ngx_http_shib_request_header_v ...@@ -760,6 +763,9 @@ ngx_http_set_header_helper(ngx_http_request_t *r, ngx_http_shib_request_header_v
h->key = hv->key; h->key = hv->key;
h->value = *value; h->value = *value;
#if defined(nginx_version) && nginx_version >= 1023000
h->next = NULL;
#endif
h->lowcase_key = ngx_pnalloc(r->pool, h->key.len); h->lowcase_key = ngx_pnalloc(r->pool, h->key.len);
if (h->lowcase_key == NULL) { if (h->lowcase_key == NULL) {
...@@ -840,6 +846,46 @@ static ngx_int_t ...@@ -840,6 +846,46 @@ static ngx_int_t
ngx_http_set_builtin_multi_header(ngx_http_request_t *r, ngx_http_set_builtin_multi_header(ngx_http_request_t *r,
ngx_http_shib_request_header_val_t *hv, ngx_str_t *value) ngx_http_shib_request_header_val_t *hv, ngx_str_t *value)
{ {
#if defined(nginx_version) && nginx_version >= 1023000
ngx_table_elt_t **headers, *h, *ho, **ph;
headers = (ngx_table_elt_t **) ((char *) &r->headers_out + hv->offset);
if (*headers) {
for (h = (*headers)->next; h; h = h->next) {
h->hash = 0;
h->value.len = 0;
}
h = *headers;
h->value = *value;
if (value->len == 0) {
h->hash = 0;
} else {
h->hash = hv->hash;
}
return NGX_OK;
}
for (ph = headers; *ph; ph = &(*ph)->next) { /* void */ }
ho = ngx_list_push(&r->headers_out.headers);
if (ho == NULL) {
return NGX_ERROR;
}
ho->value = *value;
ho->hash = hv->hash;
ngx_str_set(&ho->key, "Cache-Control");
ho->next = NULL;
*ph = ho;
return NGX_OK;
#else
ngx_array_t *pa; ngx_array_t *pa;
ngx_table_elt_t *ho, **ph; ngx_table_elt_t *ho, **ph;
ngx_uint_t i; ngx_uint_t i;
...@@ -898,6 +944,7 @@ ngx_http_set_builtin_multi_header(ngx_http_request_t *r, ...@@ -898,6 +944,7 @@ ngx_http_set_builtin_multi_header(ngx_http_request_t *r,
*ph = ho; *ph = ho;
return NGX_OK; return NGX_OK;
#endif
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment