range_filter_module get duplicated Accept-Ranges response headers

webber nginx-forum at forum.nginx.org
Wed Jul 8 04:14:06 UTC 2020


Thanks for your reply. I have tried the patch that removes the original
Accept-Ranges in slice filter module, but it is not work as my expected. 
Because I think response header `Accept-Ranges` should be added if client
send a range request.

Actually, in my production environment, my upstream server is Apache
TrafficServer, and according to RFC 7233, section 2.3:
Accept-Ranges(https://tools.ietf.org/html/rfc7233#section-2.3) , I think
original Accept-Ranges header should not be removed in all case. I changed
your patch as follow,  original Accept-Ranges header will be removed just
for no-range request , that will work for me, could you please review that?

diff --git a/src/http/modules/ngx_http_slice_filter_module.c
index c1edbca2..570deaa5 100644
--- a/src/http/modules/ngx_http_slice_filter_module.c
+++ b/src/http/modules/ngx_http_slice_filter_module.c
@@ -180,6 +180,11 @@ ngx_http_slice_header_filter(ngx_http_request_t *r)
     r->headers_out.content_range->hash = 0;
     r->headers_out.content_range = NULL;

+    if (!r->headers_in.range) {
+        r->headers_out.accept_ranges->hash = 0;
+        r->headers_out.accept_ranges = NULL;
+    }
     r->allow_ranges = 1;
     r->subrequest_ranges = 1;
     r->single_range = 1;

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,288569,288627#msg-288627

More information about the nginx mailing list