[PATCH] Tests: clearing of pre-existing Content-Range headers

Maxim Dounin mdounin at mdounin.ru
Fri Oct 21 22:12:38 UTC 2022


Hello!

On Fri, Oct 21, 2022 at 07:55:34AM -0700, Eugene Grebenschikov via nginx-devel wrote:

> # HG changeset patch
> # User Eugene Grebenschikov <e.grebenshchikov at f5.com>
> # Date 1666307094 25200
> #      Thu Oct 20 16:04:54 2022 -0700
> # Node ID 20ef9719316bdee06a6faf731bf76c1777bc98ba
> # Parent  4f282294d8aec6fc20d6d68690bdf800629ad606
> Tests: clearing of pre-existing Content-Range headers
> 
> diff -r 4f282294d8ae -r 20ef9719316b range.t
> --- a/range.t	Wed Oct 19 10:27:19 2022 -0700
> +++ b/range.t	Thu Oct 20 16:04:54 2022 -0700
> @@ -21,7 +21,7 @@
>  select STDERR; $| = 1;
>  select STDOUT; $| = 1;
>  
> -my $t = Test::Nginx->new()->has(qw/http charset/)->plan(41);
> +my $t = Test::Nginx->new()->has(qw/http charset proxy cache/)->plan(44);
>  
>  $t->write_file_expand('nginx.conf', <<'EOF');
>  
> @@ -39,6 +39,9 @@
>          58 59; # X -> Y
>      }
>  
> +    proxy_cache_path   %%TESTDIR%%/cache  levels=1:2
> +                       keys_zone=NAME:1m;
> +
>      server {
>          listen       127.0.0.1:8080;
>          server_name  localhost;
> @@ -55,6 +58,18 @@
>          location /t4.html {
>              max_ranges 0;
>          }
> +
> +        location /t5.html {
> +            proxy_pass http://127.0.0.1:8080/stub;
> +            proxy_cache   NAME;
> +            proxy_cache_valid 200 1m;
> +        }
> +
> +        location /stub {
> +            add_header Content-Range stub;
> +            add_header Accept-Ranges bytes;
> +            return 200 "SEE-THIS";
> +        }
>      }
>  }
>  
> @@ -154,6 +169,20 @@
>  unlike(http_get_range('/t4.html', 'Range: bytes=0-9'), qr/ 206 /,
>  	'max_ranges zero');
>  
> +# clearing of pre-existing Content-Range headers
> +
> +TODO: {
> +local $TODO = 'not yet' unless $t->has_version('1.23.1');
> +
> +like(http_get_range('/t5.html', 'Range: bytes=0-4'),
> +    qr/ 206 (?!.*stub)/s, 'content range cleared - range request');
> +like(http_get_range('/t5.html', 'Range: bytes=0-2,4-'),
> +    qr/ 206 (?!.*stub)/s, 'content range cleared - multipart');
> +like(http_get_range('/t5.html', 'Range: bytes=1000-'),
> +    qr/ 416 (?!.*stub)/s, 'content range cleared - not satisfable');
> +
> +}
> +
>  ###############################################################################
>  
>  sub http_get_range {

It might be a good idea to keep this separate from the basic range 
filter tests.  E.g., in a separate file, similarly to 
range_charset.t tests.  Or in a generic test file for tests with 
proxying, that is, combined with range_charset.t.

This approach ensures that even a stripped-down nginx version, 
such as one compiled with "--without-http_proxy_module", can be 
properly tested by the test suite.

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



More information about the nginx-devel mailing list