Skip to content

Commit be22ac0

Browse files
authored
bugfix: Update handling of cache_control changed in nginx 1.23.0 (Fixes #96) (#97)
1 parent 0e99d1d commit be22ac0

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ env:
2525
matrix:
2626
- NGINX_VERSION=1.17.8
2727
- NGINX_VERSION=1.19.9
28+
- NGINX_VERSION=1.23.0
2829

2930
services:
3031
- memcache

src/ngx_http_srcache_headers.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,17 @@ static ngx_int_t
256256
ngx_http_srcache_process_multi_header_lines(ngx_http_request_t *r,
257257
ngx_table_elt_t *h, ngx_uint_t offset)
258258
{
259+
#if defined(nginx_version) && nginx_version < 1023000
259260
ngx_array_t *pa;
261+
#endif
260262
ngx_table_elt_t *ho, **ph;
261263

264+
#if defined(nginx_version) && nginx_version >= 1023000
265+
ph = (ngx_table_elt_t **) ((char *) &r->headers_out + offset);
266+
while (*ph) {
267+
ph = &(*ph)->next;
268+
}
269+
#else
262270
pa = (ngx_array_t *) ((char *) &r->headers_out + offset);
263271

264272
if (pa->elts == NULL) {
@@ -272,6 +280,7 @@ ngx_http_srcache_process_multi_header_lines(ngx_http_request_t *r,
272280
if (ph == NULL) {
273281
return NGX_ERROR;
274282
}
283+
#endif
275284

276285
ho = ngx_list_push(&r->headers_out.headers);
277286
if (ho == NULL) {
@@ -280,6 +289,9 @@ ngx_http_srcache_process_multi_header_lines(ngx_http_request_t *r,
280289

281290
*ho = *h;
282291
*ph = ho;
292+
#if defined(nginx_version) && nginx_version >= 1023000
293+
ho->next = NULL;
294+
#endif
283295

284296
return NGX_OK;
285297
}

src/ngx_http_srcache_util.c

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,15 +546,34 @@ ngx_int_t
546546
ngx_http_srcache_response_no_cache(ngx_http_request_t *r,
547547
ngx_http_srcache_loc_conf_t *conf, ngx_http_srcache_ctx_t *ctx)
548548
{
549-
ngx_table_elt_t **ccp;
550549
ngx_table_elt_t *h;
550+
#if defined(nginx_version) && nginx_version >= 1023000
551+
ngx_table_elt_t *cc;
552+
#else
553+
ngx_table_elt_t **ccp;
551554
ngx_uint_t i;
555+
#endif
552556
u_char *p, *last;
553557
ngx_int_t n;
554558
time_t expires;
555559

556560
dd("checking response cache control settings");
557561

562+
#if defined(nginx_version) && nginx_version >= 1023000
563+
cc = r->headers_out.cache_control;
564+
565+
if (cc == NULL) {
566+
goto check_expires;
567+
}
568+
569+
for (; cc; cc = cc->next) {
570+
if (!cc->hash) {
571+
continue;
572+
}
573+
574+
p = cc->value.data;
575+
last = p + cc->value.len;
576+
#else
558577
ccp = r->headers_out.cache_control.elts;
559578

560579
if (ccp == NULL) {
@@ -568,6 +587,7 @@ ngx_http_srcache_response_no_cache(ngx_http_request_t *r,
568587

569588
p = ccp[i]->value.data;
570589
last = p + ccp[i]->value.len;
590+
#endif
571591

572592
if (!conf->store_private
573593
&& ngx_strlcasestrn(p, last, (u_char *) "private", 7 - 1) != NULL)

0 commit comments

Comments
 (0)