Mercurial > hg > nginx-tests
annotate post_action.t @ 1606:e4e0695552ed
Tests: fixed stream_proxy_ssl_conf_command.t.
The stream_proxy_ssl_conf_command.t test used stream return module
to return the response. Since this ignores actual request, but the
perl test code used http_get(). This might result in the request being
sent after the response is returned and the connection closed by the server,
resulting in RST being generated and no response seen by the client at all.
Fix is to use "stream(...)->read()" instead of http_get(), so
no request is sent at all, eliminating possibility of RST being
generated.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Tue, 10 Nov 2020 05:03:29 +0300 |
parents | 882267679006 |
children |
rev | line source |
---|---|
453 | 1 #!/usr/bin/perl |
2 | |
3 # (C) Maxim Dounin | |
4 # (C) Nginx, Inc. | |
5 | |
6 # Tests for nginx post_action directive. | |
7 | |
8 ############################################################################### | |
9 | |
10 use warnings; | |
11 use strict; | |
12 | |
13 use Test::More; | |
14 | |
15 BEGIN { use FindBin; chdir($FindBin::Bin); } | |
16 | |
17 use lib 'lib'; | |
18 use Test::Nginx; | |
19 | |
20 ############################################################################### | |
21 | |
22 select STDERR; $| = 1; | |
23 select STDOUT; $| = 1; | |
24 | |
593
6c0a5903d0ae
Tests: cleanup now duplicating tests for no alerts.
Sergey Kandaurov <pluknet@nginx.com>
parents:
548
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(5); |
453 | 26 |
27 $t->write_file_expand('nginx.conf', <<'EOF'); | |
28 | |
29 %%TEST_GLOBALS%% | |
30 | |
31 daemon off; | |
32 | |
33 events { | |
34 } | |
35 | |
36 http { | |
37 %%TEST_GLOBALS_HTTP%% | |
38 | |
39 server { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
40 listen 127.0.0.1:8080; |
453 | 41 server_name localhost; |
42 | |
43 location / { | |
44 post_action /post.html; | |
45 } | |
46 | |
47 location /post.html { | |
48 # static | |
49 } | |
50 | |
51 location /remote { | |
52 post_action /post.remote; | |
53 } | |
54 | |
55 location /post.remote { | |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
56 proxy_pass http://127.0.0.1:8080/post.html; |
453 | 57 } |
58 } | |
59 } | |
60 | |
61 EOF | |
62 | |
63 $t->write_file('index.html', 'SEE-THIS'); | |
64 $t->write_file('post.html', 'HIDDEN'); | |
65 $t->write_file('remote', 'SEE-THIS'); | |
66 | |
67 $t->run(); | |
68 | |
69 ############################################################################### | |
70 | |
71 like(http_get('/'), qr/SEE-THIS/m, 'post action'); | |
72 unlike(http_get('/'), qr/HIDDEN/m, 'no additional body'); | |
73 | |
74 like(http_get('/remote'), qr/SEE-THIS/m, 'post action proxy'); | |
75 unlike(http_get('/remote'), qr/HIDDEN/m, 'no additional body proxy'); | |
76 | |
77 $t->stop(); | |
78 | |
79 like(`cat ${\($t->testdir())}/access.log`, qr/post/, 'post action in logs'); | |
80 | |
81 ############################################################################### |