[PATCH] Gzip static: ranges support (ticket #2349)

Maxim Dounin mdounin at mdounin.ru
Sat Jan 14 00:01:51 UTC 2023


Hello!

On Tue, Jan 03, 2023 at 05:48:36AM +0300, Maxim Dounin wrote:

> # HG changeset patch
> # User Maxim Dounin <mdounin at mdounin.ru>
> # Date 1672713976 -10800
> #      Tue Jan 03 05:46:16 2023 +0300
> # Node ID e0688b4494f02dcf6feebf0c73e02749bd7de381
> # Parent  07b0bee87f32be91a33210bc06973e07c4c1dac9
> Gzip static: ranges support (ticket #2349).
> 
> In contrast to on-the-fly gzipping with gzip filter, static gzipped
> representation as returned by gzip_static is persistent, and therefore
> the same binary representation is available for future requests, making
> it possible to use range requests.
> 
> Further, if a gzipped representation is re-generated with different
> compression settings, it is expected to result in different ETag and
> different size reported in the Content-Range header, making it possible
> to safely use range requests anyway.
> 
> As such, ranges are now allowed for files returned by gzip_static.
> 
> diff --git a/src/http/modules/ngx_http_gzip_static_module.c b/src/http/modules/ngx_http_gzip_static_module.c
> --- a/src/http/modules/ngx_http_gzip_static_module.c
> +++ b/src/http/modules/ngx_http_gzip_static_module.c
> @@ -247,6 +247,8 @@ ngx_http_gzip_static_handler(ngx_http_re
>      ngx_str_set(&h->value, "gzip");
>      r->headers_out.content_encoding = h;
>  
> +    r->allow_ranges = 1;
> +
>      /* we need to allocate all before the header would be sent */
>  
>      b = ngx_calloc_buf(r->pool);

Ping.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx-devel mailing list