Mercurial > hg > nginx-tests
annotate sub_filter_slice.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 8659123d2d37 |
children |
rev | line source |
---|---|
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for slice filter with sub filter. |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 # A response is sent using chunked encoding. |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 ############################################################################### |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 use warnings; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use strict; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 use Test::More; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 BEGIN { use FindBin; chdir($FindBin::Bin); } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 use lib 'lib'; |
1612
8659123d2d37
Tests: made http_content() exportable.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1251
diff
changeset
|
20 use Test::Nginx qw/ :DEFAULT http_content /; |
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 ############################################################################### |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 select STDERR; $| = 1; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 select STDOUT; $| = 1; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http proxy slice sub/)->plan(3); |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 $t->write_file_expand('nginx.conf', <<'EOF'); |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 %%TEST_GLOBALS%% |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 daemon off; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 events { |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 http { |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 %%TEST_GLOBALS_HTTP%% |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server { |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 listen 127.0.0.1:8080; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 location / { |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 sub_filter foo bar; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 sub_filter_types *; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 slice 2; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 proxy_pass http://127.0.0.1:8081/; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 proxy_set_header Range $slice_range; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 server { |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 listen 127.0.0.1:8081; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 server_name localhost; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 location / { } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 EOF |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 $t->write_file('t', '0123456789'); |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 $t->run(); |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 ############################################################################### |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 my $r; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 # range filter in subrequests (subrequest_ranges) |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 $r = get('/t', 'Range: bytes=2-4'); |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 unlike($r, qr/\x0d\x0a?0\x0d\x0a?\x0d\x0a?\w/, 'only final chunk'); |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 TODO: { |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 local $TODO = 'not yet'; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 # server is assumed to return the requested range |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 $r = get('/t', 'Range: bytes=3-4'); |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 like($r, qr/ 206 /, 'range request - 206 partial reply'); |
1612
8659123d2d37
Tests: made http_content() exportable.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1251
diff
changeset
|
86 is(http_content($r), '34', 'range request - correct content'); |
1056
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 ############################################################################### |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 sub get { |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 my ($url, $extra) = @_; |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 return http(<<EOF); |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 GET $url HTTP/1.1 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 Host: localhost |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 Connection: close |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 $extra |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 EOF |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 } |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 |
1e41a0de0772
Tests: various last_buf tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 ############################################################################### |