Skip to content

Commit 86c8edb

Browse files
committed
adjust pointers to last elements in lists when needed
when copying objects of type ngx_list_t, pointers last must be set to part if there is only one part in the list, otherwise further additions to the target list may affect only the source list; particularly, gzip module may add a Content-Encoding header which, in case of failure, may break HTTP response as the response body will still be gzipped
1 parent acadd85 commit 86c8edb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ngx_http_combined_upstreams_module.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,16 @@ ngx_http_upstrand_response_header_filter(ngx_http_request_t *r)
468468
r->main->headers_out = r->headers_out;
469469
/* FIXME: must other fields like upstream_states be copied too? */
470470

471+
/* adjust pointers to last elements in lists when needed */
472+
if (r->headers_out.headers.last == &r->headers_out.headers.part) {
473+
r->main->headers_out.headers.last =
474+
&r->main->headers_out.headers.part;
475+
}
476+
if (r->headers_out.trailers.last == &r->headers_out.trailers.part) {
477+
r->main->headers_out.trailers.last =
478+
&r->main->headers_out.trailers.part;
479+
}
480+
471481
return ngx_http_next_header_filter(r->main);
472482
}
473483

0 commit comments

Comments
 (0)