[PATCH] slice and gzip problem

Sangdeuk Kwon sangdeuk.kwon at quantil.com
Tue Aug 4 04:43:40 UTC 2020


# HG changeset patch
# User Sangdeuk Kwon <sangdeuk.kwon at quantil.com>
# Date 1596515879 -32400
#      Tue Aug 04 13:37:59 2020 +0900
# Node ID 6ed0cfe89f288587b6815333bab798d6aedc6137
# Parent  da8d758aabebbba833405463aa5a785b4c324495
slice and gzip problem

When slice is enabled, client request content with "Accept-Encoding: gzip"
and "Range: bytes=2048-3071",
nginx serves only partial gzipped content with "200 OK" instead of "206
Parital Content".
This response is wrong because nginx reply "200 OK" even if it serves only
partial content.
Client thinks he receives whole content because of "200 OK".

ngx_http_gzip_filter_module is higher priority than
ngx_http_slice_filter_module.
gzip_filter_module remove slice_filter_module's info when gzip is invoked.
So, nginx reply "200 OK" with gzipped whole content.

But, what if user request has "Range" header (only one slice case),
nginx can't access the previous slice of user request's.
It means nginx can't serve correct content if gzip_filter_module remove
slice's info.
nginx can serve correct content with "206 Partial Content" without gzip
because nginx can't access whole content.

If user reuqest has "Range" header (only one slice case), gzip_filter
should be disabled instead of slice_filter.

diff -r da8d758aabeb -r 6ed0cfe89f28
src/http/modules/ngx_http_gzip_filter_module.c
--- a/src/http/modules/ngx_http_gzip_filter_module.c Mon Jul 27 16:02:15
2020 +0300
+++ b/src/http/modules/ngx_http_gzip_filter_module.c Tue Aug 04 13:37:59
2020 +0900
@@ -233,6 +233,8 @@
             && r->headers_out.content_encoding->value.len)
         || (r->headers_out.content_length_n != -1
             && r->headers_out.content_length_n < conf->min_length)
+        || (r->allow_ranges && r == r->main
+            && r->headers_out.content_offset > 0)
         || ngx_http_test_content_type(r, &conf->types) == NULL
         || r->header_only)
     {
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20200804/1d953c0e/attachment.htm>


More information about the nginx-devel mailing list