diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2022-07-15 07:01:44 +0300 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2022-07-15 07:01:44 +0300 |
commit | f35475c083d4cfe56647b66387b60c55e25c27d0 (patch) | |
tree | 1bc937d3dec0c4575549292d82450cb69ca83d83 | |
parent | 14341ce2377d38a268261e0fec65b6915ae6e95e (diff) |
Range filter: clearing of pre-existing Content-Range headers.
Some servers might emit Content-Range header on 200 responses, and this
does not seem to contradict RFC 9110: as per RFC 9110, the Content-Range
header has no meaning for status codes other than 206 and 416. Previously
this resulted in duplicate Content-Range headers in nginx responses handled
by the range filter. Fix is to clear pre-existing headers.
-rw-r--r-- | src/http/modules/ngx_http_range_filter_module.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/src/http/modules/ngx_http_range_filter_module.c b/src/http/modules/ngx_http_range_filter_module.c index fa408b792..27d1875c8 100644 --- a/src/http/modules/ngx_http_range_filter_module.c +++ b/src/http/modules/ngx_http_range_filter_module.c @@ -425,6 +425,10 @@ ngx_http_range_singlepart_header(ngx_http_request_t *r, return NGX_ERROR; } + if (r->headers_out.content_range) { + r->headers_out.content_range->hash = 0; + } + r->headers_out.content_range = content_range; content_range->hash = 1; @@ -582,6 +586,11 @@ ngx_http_range_multipart_header(ngx_http_request_t *r, r->headers_out.content_length = NULL; } + if (r->headers_out.content_range) { + r->headers_out.content_range->hash = 0; + r->headers_out.content_range = NULL; + } + return ngx_http_next_header_filter(r); } @@ -598,6 +607,10 @@ ngx_http_range_not_satisfiable(ngx_http_request_t *r) return NGX_ERROR; } + if (r->headers_out.content_range) { + r->headers_out.content_range->hash = 0; + } + r->headers_out.content_range = content_range; content_range->hash = 1; |