Mercurial > hg > nginx-tests
annotate proxy_unfinished.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | d7ec131d305a |
children |
rev | line source |
---|---|
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
2 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
3 # (C) Maxim Dounin |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
4 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
5 # Tests for http proxy and prematurely closed connections. Incomplete |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
6 # responses shouldn't loose information about their incompleteness. |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
7 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
8 # In particular, incomplete responses: |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
9 # |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
10 # - shouldn't be cached |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
11 # |
343
e7dc8f4d0a4b
Tests: whitespace and spelling fixes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
319
diff
changeset
|
12 # - if a response is sent using chunked transfer encoding, |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
13 # final chunk shouldn't be sent |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
14 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
15 ############################################################################### |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
16 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
17 use warnings; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
18 use strict; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
19 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
20 use Test::More; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
21 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
22 use Socket qw/ CRLF /; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
23 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
24 BEGIN { use FindBin; chdir($FindBin::Bin); } |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
25 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
26 use lib 'lib'; |
1612
8659123d2d37
Tests: made http_content() exportable.
Maxim Dounin <mdounin@mdounin.ru>
parents:
1043
diff
changeset
|
27 use Test::Nginx qw/ :DEFAULT http_content /; |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
28 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
29 ############################################################################### |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
30 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
31 select STDERR; $| = 1; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
32 select STDOUT; $| = 1; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
33 |
1020
196d33c2bb45
Tests: removed TODO and try_run() checks for legacy versions.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
974
diff
changeset
|
34 my $t = Test::Nginx->new()->has(qw/http proxy cache sub/)->plan(15); |
598
153969b53780
Tests: expect occasional alerts on solaris in certain tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
35 |
153969b53780
Tests: expect occasional alerts on solaris in certain tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
589
diff
changeset
|
36 $t->write_file_expand('nginx.conf', <<'EOF'); |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
37 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
38 %%TEST_GLOBALS%% |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
39 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
40 daemon off; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
41 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
42 events { |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
43 } |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
44 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
45 http { |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
46 %%TEST_GLOBALS_HTTP%% |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
47 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
48 proxy_cache_path %%TESTDIR%%/cache levels=1:2 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
49 keys_zone=one:1m; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
50 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
51 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
52 listen 127.0.0.1:8080 sndbuf=32k; |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
53 server_name localhost; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
54 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
55 location / { |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
56 sub_filter foo bar; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
57 sub_filter_types *; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
58 proxy_pass http://127.0.0.1:8081; |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
59 } |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
60 |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
61 location /un/ { |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
62 sub_filter foo bar; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
63 sub_filter_types *; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
64 proxy_pass http://127.0.0.1:8081/; |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
65 proxy_buffering off; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
66 } |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
67 |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
68 location /cache/ { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
69 proxy_pass http://127.0.0.1:8081/; |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
70 proxy_cache one; |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
71 add_header X-Cache-Status $upstream_cache_status; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
72 } |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
73 |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
74 location /proxy/ { |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
75 sub_filter foo bar; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
76 sub_filter_types *; |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
77 proxy_pass http://127.0.0.1:8080/local/; |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
78 proxy_buffer_size 1k; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
79 proxy_buffers 4 1k; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
80 } |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
81 |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
82 location /local/ { |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
83 alias %%TESTDIR%%/; |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
84 } |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
85 } |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
86 } |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
87 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
88 EOF |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
89 |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
90 $t->write_file('big.html', 'X' x (1024 * 1024) . 'finished'); |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
91 |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
92 $t->run_daemon(\&http_daemon); |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
93 $t->run()->waitforsocket('127.0.0.1:' . port(8081)); |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
94 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
95 ############################################################################### |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
96 |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
97 http_get('/cache/length'); |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
98 like(http_get('/cache/length'), qr/MISS/, 'unfinished not cached'); |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
99 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
100 # chunked encoding has enough information to don't cache a response, |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
101 # much like with Content-Length available |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
102 |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
103 http_get('/cache/chunked'); |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
104 like(http_get('/cache/chunked'), qr/MISS/, 'unfinished chunked'); |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
105 |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
106 # make sure there is no final chunk in unfinished responses |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
107 |
1613
d7ec131d305a
Tests: reworked proxy_unfinished.t to use http_content().
Maxim Dounin <mdounin@mdounin.ru>
parents:
1612
diff
changeset
|
108 like(http_get_11('/length'), qr/unfinished.*no-last-chunk/s, |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
109 'length no final chunk'); |
1613
d7ec131d305a
Tests: reworked proxy_unfinished.t to use http_content().
Maxim Dounin <mdounin@mdounin.ru>
parents:
1612
diff
changeset
|
110 like(http_get_11('/chunked'), qr/unfinished.*no-last-chunk/s, |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
111 'chunked no final chunk'); |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
112 |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
113 # but there is final chunk in complete responses |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
114 |
1613
d7ec131d305a
Tests: reworked proxy_unfinished.t to use http_content().
Maxim Dounin <mdounin@mdounin.ru>
parents:
1612
diff
changeset
|
115 like(http_get_11('/length/ok'), qr/finished\x0d\x0a$/s, |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
116 'length final chunk'); |
1613
d7ec131d305a
Tests: reworked proxy_unfinished.t to use http_content().
Maxim Dounin <mdounin@mdounin.ru>
parents:
1612
diff
changeset
|
117 like(http_get_11('/chunked/ok'), qr/finished\x0d\x0a$/s, |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
118 'chunked final chunk'); |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
119 |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
120 # the same with proxy_buffering set to off |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
121 |
1613
d7ec131d305a
Tests: reworked proxy_unfinished.t to use http_content().
Maxim Dounin <mdounin@mdounin.ru>
parents:
1612
diff
changeset
|
122 like(http_get_11('/un/length'), qr/unfinished.*no-last-chunk/s, |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
123 'unbuffered length no final chunk'); |
1613
d7ec131d305a
Tests: reworked proxy_unfinished.t to use http_content().
Maxim Dounin <mdounin@mdounin.ru>
parents:
1612
diff
changeset
|
124 like(http_get_11('/un/chunked'), qr/unfinished.*no-last-chunk/s, |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
125 'unbuffered chunked no final chunk'); |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
126 |
1613
d7ec131d305a
Tests: reworked proxy_unfinished.t to use http_content().
Maxim Dounin <mdounin@mdounin.ru>
parents:
1612
diff
changeset
|
127 like(http_get_11('/un/length/ok'), qr/finished\x0d\x0a$/s, |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
128 'unbuffered length final chunk'); |
1613
d7ec131d305a
Tests: reworked proxy_unfinished.t to use http_content().
Maxim Dounin <mdounin@mdounin.ru>
parents:
1612
diff
changeset
|
129 like(http_get_11('/un/chunked/ok'), qr/finished\x0d\x0a$/s, |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
130 'unbuffered chunked final chunk'); |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
131 |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
132 # big responses |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
133 |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
134 like(http_get('/big', sleep => 0.1), qr/unfinished/s, 'big unfinished'); |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
135 like(http_get('/big/ok', sleep => 0.1), qr/finished/s, 'big finished'); |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
136 like(http_get('/un/big', sleep => 0.1), qr/unfinished/s, 'big unfinished un'); |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
137 like(http_get('/un/big/ok', sleep => 0.1), qr/finished/s, 'big finished un'); |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
138 |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
139 # if disk buffering fails for some reason, there should be |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
140 # no final chunk |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
141 |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
142 chmod(0000, $t->testdir() . '/proxy_temp'); |
1043
b82f54728e14
Tests: fixed test failure in proxy_unfinished.t with big buffers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
143 |
b82f54728e14
Tests: fixed test failure in proxy_unfinished.t with big buffers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
144 my $r = http_get_11('/proxy/big.html', sleep => 0.5); |
b82f54728e14
Tests: fixed test failure in proxy_unfinished.t with big buffers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
145 |
b82f54728e14
Tests: fixed test failure in proxy_unfinished.t with big buffers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
146 SKIP: { |
1613
d7ec131d305a
Tests: reworked proxy_unfinished.t to use http_content().
Maxim Dounin <mdounin@mdounin.ru>
parents:
1612
diff
changeset
|
147 skip 'finished', 1 if length($r) == 1024 * 1024 + 8; |
1043
b82f54728e14
Tests: fixed test failure in proxy_unfinished.t with big buffers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
148 |
b82f54728e14
Tests: fixed test failure in proxy_unfinished.t with big buffers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
149 like($r, qr/X(?!.*\x0d\x0a?0\x0d\x0a?)/s, 'no proxy temp'); |
b82f54728e14
Tests: fixed test failure in proxy_unfinished.t with big buffers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
150 |
b82f54728e14
Tests: fixed test failure in proxy_unfinished.t with big buffers.
Sergey Kandaurov <pluknet@nginx.com>
parents:
1020
diff
changeset
|
151 } |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
152 |
939
cfddaf316233
Tests: restored proxy_temp_path access bits in proxy_unfinished.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
891
diff
changeset
|
153 chmod(0700, $t->testdir() . '/proxy_temp'); |
cfddaf316233
Tests: restored proxy_temp_path access bits in proxy_unfinished.t.
Sergey Kandaurov <pluknet@nginx.com>
parents:
891
diff
changeset
|
154 |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
155 ############################################################################### |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
156 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
157 sub http_get_11 { |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
158 my ($uri, %extra) = @_; |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
159 |
1613
d7ec131d305a
Tests: reworked proxy_unfinished.t to use http_content().
Maxim Dounin <mdounin@mdounin.ru>
parents:
1612
diff
changeset
|
160 return http_content(http( |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
161 "GET $uri HTTP/1.1" . CRLF . |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
162 "Connection: close" . CRLF . |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
163 "Host: localhost" . CRLF . CRLF, |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
164 %extra |
1613
d7ec131d305a
Tests: reworked proxy_unfinished.t to use http_content().
Maxim Dounin <mdounin@mdounin.ru>
parents:
1612
diff
changeset
|
165 )); |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
166 } |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
167 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
168 ############################################################################### |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
169 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
170 sub http_daemon { |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
171 my $server = IO::Socket::INET->new( |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
172 Proto => 'tcp', |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
173 LocalAddr => '127.0.0.1:' . port(8081), |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
174 Listen => 5, |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
175 Reuse => 1 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
176 ) |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
177 or die "Can't create listening socket: $!\n"; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
178 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
179 local $SIG{PIPE} = 'IGNORE'; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
180 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
181 while (my $client = $server->accept()) { |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
182 $client->autoflush(1); |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
183 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
184 my $headers = ''; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
185 my $uri = ''; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
186 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
187 while (<$client>) { |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
188 $headers .= $_; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
189 last if (/^\x0d?\x0a?$/); |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
190 } |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
191 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
192 $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
193 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
194 if ($uri eq '/length') { |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
195 print $client |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
196 "HTTP/1.1 200 OK" . CRLF . |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
197 "Content-Length: 100" . CRLF . |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
198 "Cache-Control: max-age=300" . CRLF . |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
199 "Connection: close" . CRLF . |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
200 CRLF . |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
201 "unfinished" . CRLF; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
202 |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
203 } elsif ($uri eq '/length/ok') { |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
204 print $client |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
205 "HTTP/1.1 200 OK" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
206 "Content-Length: 10" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
207 "Cache-Control: max-age=300" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
208 "Connection: close" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
209 CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
210 "finished" . CRLF; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
211 |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
212 } elsif ($uri eq '/big') { |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
213 print $client |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
214 "HTTP/1.1 200 OK" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
215 "Content-Length: 1000100" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
216 "Cache-Control: max-age=300" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
217 "Connection: close" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
218 CRLF; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
219 for (1 .. 10000) { |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
220 print $client ("X" x 98) . CRLF; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
221 } |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
222 print $client "unfinished" . CRLF; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
223 |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
224 } elsif ($uri eq '/big/ok') { |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
225 print $client |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
226 "HTTP/1.1 200 OK" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
227 "Content-Length: 1000010" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
228 "Cache-Control: max-age=300" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
229 "Connection: close" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
230 CRLF; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
231 for (1 .. 10000) { |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
232 print $client ("X" x 98) . CRLF; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
233 } |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
234 print $client "finished" . CRLF; |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
235 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
236 } elsif ($uri eq '/chunked') { |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
237 print $client |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
238 "HTTP/1.1 200 OK" . CRLF . |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
239 "Transfer-Encoding: chunked" . CRLF . |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
240 "Cache-Control: max-age=300" . CRLF . |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
241 "Connection: close" . CRLF . |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
242 CRLF . |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
243 "ff" . CRLF . |
307
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
244 "unfinished" . CRLF; |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
245 |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
246 } elsif ($uri eq '/chunked/ok') { |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
247 print $client |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
248 "HTTP/1.1 200 OK" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
249 "Transfer-Encoding: chunked" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
250 "Cache-Control: max-age=300" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
251 "Connection: close" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
252 CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
253 "a" . CRLF . |
81c98592661f
Tests: more unfinished tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
299
diff
changeset
|
254 "finished" . CRLF . |
589
a9569f57da98
Tests: whitespaces fix.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
574
diff
changeset
|
255 CRLF . "0" . CRLF . CRLF; |
299
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
256 } |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
257 } |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
258 } |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
259 |
44c42894fdfd
Tests: move unfinished tests to a separate file.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff
changeset
|
260 ############################################################################### |