Mercurial > hg > nginx-tests
annotate range_clearing.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | a095b971fbcc |
children |
rev | line source |
---|---|
1809
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
2 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
3 # (C) Eugene Grebenschikov |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
4 # (C) Sergey Kandaurov |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
5 # (C) Nginx, Inc. |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
6 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
7 # Tests for clearing of pre-existing Content-Range headers. |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
8 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
9 ############################################################################### |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
10 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
11 use warnings; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
12 use strict; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
13 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
14 use Test::More; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
15 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
16 BEGIN { use FindBin; chdir($FindBin::Bin); } |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
17 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
18 use lib 'lib'; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
19 use Test::Nginx; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
20 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
21 ############################################################################### |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
22 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
23 select STDERR; $| = 1; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
24 select STDOUT; $| = 1; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
25 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
26 my $t = Test::Nginx->new()->has(qw/http rewrite proxy cache/) |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
27 ->write_file_expand('nginx.conf', <<'EOF'); |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
28 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
29 %%TEST_GLOBALS%% |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
30 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
31 daemon off; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
32 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
33 events { |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
34 } |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
35 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
36 http { |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
37 %%TEST_GLOBALS_HTTP%% |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
38 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
39 proxy_cache_path %%TESTDIR%%/cache levels=1:2 keys_zone=NAME:1m; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
40 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
41 server { |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
42 listen 127.0.0.1:8080; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
44 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
45 location / { |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
46 proxy_pass http://127.0.0.1:8080/stub; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
47 proxy_cache NAME; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
48 proxy_cache_valid 200 1m; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
49 } |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
50 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
51 location /stub { |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
52 add_header Content-Range stub; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
53 add_header Accept-Ranges bytes; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
54 return 200 "SEE-THIS"; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
55 } |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
56 } |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
57 } |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
58 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
59 EOF |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
60 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
61 $t->run()->plan(3); |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
62 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
63 ############################################################################### |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
64 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
65 like(http_get_range('/', 'Range: bytes=0-4'), |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
66 qr/ 206 (?!.*stub)/s, 'content range cleared - range request'); |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
67 like(http_get_range('/', 'Range: bytes=0-2,4-'), |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
68 qr/ 206 (?!.*stub)/s, 'content range cleared - multipart'); |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
69 like(http_get_range('/', 'Range: bytes=1000-'), |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
70 qr/ 416 (?!.*stub)/s, 'content range cleared - not satisfable'); |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
71 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
72 ############################################################################### |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
73 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
74 sub http_get_range { |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
75 my ($url, $extra) = @_; |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
76 return http(<<EOF); |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
77 GET $url HTTP/1.1 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
78 Host: localhost |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
79 Connection: close |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
80 $extra |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
81 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
82 EOF |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
83 } |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
84 |
c41ac260299f
Tests: clearing of pre-existing Content-Range headers.
Eugene Grebenschikov <e.grebenshchikov@nginx.com>
parents:
diff
changeset
|
85 ############################################################################### |