Skip to content

Commit 20819c8

Browse files
committed
nginx 1.23
1 parent ead73a5 commit 20819c8

File tree

1 file changed

+16
-18
lines changed

1 file changed

+16
-18
lines changed

src/ngx_http_push_stream_module_utils.c

+16-18
Original file line numberDiff line numberDiff line change
@@ -2194,8 +2194,7 @@ ngx_http_push_stream_set_expires(ngx_http_request_t *r, ngx_http_push_stream_exp
21942194
{
21952195
size_t len;
21962196
time_t now, expires_header_time, max_age;
2197-
ngx_uint_t i;
2198-
ngx_table_elt_t *expires_header, *cc, **ccp;
2197+
ngx_table_elt_t *expires_header, *cc;
21992198

22002199
expires_header = r->headers_out.expires;
22012200

@@ -2207,6 +2206,7 @@ ngx_http_push_stream_set_expires(ngx_http_request_t *r, ngx_http_push_stream_exp
22072206
}
22082207

22092208
r->headers_out.expires = expires_header;
2209+
expires_header->next = NULL;
22102210

22112211
expires_header->hash = 1;
22122212
ngx_str_set(&expires_header->key, "Expires");
@@ -2215,34 +2215,29 @@ ngx_http_push_stream_set_expires(ngx_http_request_t *r, ngx_http_push_stream_exp
22152215
len = sizeof("Mon, 28 Sep 1970 06:00:00 GMT");
22162216
expires_header->value.len = len - 1;
22172217

2218-
ccp = r->headers_out.cache_control.elts;
2218+
cc = r->headers_out.cache_control;
22192219

2220-
if (ccp == NULL) {
2221-
2222-
if (ngx_array_init(&r->headers_out.cache_control, r->pool, 1, sizeof(ngx_table_elt_t *)) != NGX_OK) {
2223-
return NGX_ERROR;
2224-
}
2225-
2226-
ccp = ngx_array_push(&r->headers_out.cache_control);
2227-
if (ccp == NULL) {
2228-
return NGX_ERROR;
2229-
}
2220+
if (cc == NULL) {
22302221

22312222
cc = ngx_list_push(&r->headers_out.headers);
22322223
if (cc == NULL) {
2224+
expires_header->hash = 0;
22332225
return NGX_ERROR;
22342226
}
22352227

2228+
r->headers_out.cache_control = cc;
2229+
cc->next = NULL;
2230+
22362231
cc->hash = 1;
22372232
ngx_str_set(&cc->key, "Cache-Control");
2238-
*ccp = cc;
22392233

22402234
} else {
2241-
for (i = 1; i < r->headers_out.cache_control.nelts; i++) {
2242-
ccp[i]->hash = 0;
2235+
for (cc = cc->next; cc; cc = cc->next) {
2236+
cc->hash = 0;
22432237
}
22442238

2245-
cc = ccp[0];
2239+
cc = r->headers_out.cache_control;
2240+
cc->next = NULL;
22462241
}
22472242

22482243
if (expires == NGX_HTTP_PUSH_STREAM_EXPIRES_EPOCH) {
@@ -2260,6 +2255,8 @@ ngx_http_push_stream_set_expires(ngx_http_request_t *r, ngx_http_push_stream_exp
22602255

22612256
expires_header->value.data = ngx_pnalloc(r->pool, len);
22622257
if (expires_header->value.data == NULL) {
2258+
expires_header->hash = 0;
2259+
cc->hash = 0;
22632260
return NGX_ERROR;
22642261
}
22652262

@@ -2276,8 +2273,8 @@ ngx_http_push_stream_set_expires(ngx_http_request_t *r, ngx_http_push_stream_exp
22762273
max_age = expires_header_time - now;
22772274

22782275
} else if (expires == NGX_HTTP_PUSH_STREAM_EXPIRES_ACCESS || r->headers_out.last_modified_time == -1) {
2279-
expires_header_time = now + expires_time;
22802276
max_age = expires_time;
2277+
expires_header_time = now + expires_time;
22812278

22822279
} else {
22832280
expires_header_time = r->headers_out.last_modified_time + expires_time;
@@ -2293,6 +2290,7 @@ ngx_http_push_stream_set_expires(ngx_http_request_t *r, ngx_http_push_stream_exp
22932290

22942291
cc->value.data = ngx_pnalloc(r->pool, sizeof("max-age=") + NGX_TIME_T_LEN + 1);
22952292
if (cc->value.data == NULL) {
2293+
cc->hash = 0;
22962294
return NGX_ERROR;
22972295
}
22982296

0 commit comments

Comments
 (0)