annotate ssi.t @ 1961:fe6f22da53ec default tip

Tests: tests for usage of discarded body. The client_max_body_size limit should be ignored when the request body is already discarded. In HTTP/1.x, this is done by checking the r->discard_body flag when the body is being discarded, and because r->headers_in.content_length_n is 0 when it's already discarded. This, however, does not happen with HTTP/2 and HTTP/3, and therefore "error_page 413" does not work without relaxing the limit. Further, with proxy_pass, r->headers_in.content_length_n is used to determine length of the request body, and therefore is not correct if discarding of the request body isn't yet complete. While discarding the request body, r->headers_in.content_length_n contains the rest of the body to discard (or, in case of chunked request body, the rest of the current chunk to discard). Similarly, the $content_length variable uses r->headers_in.content_length if available, and also incorrect. The $content_length variable is used when proxying with fastcgi_pass, grpc_pass, and uwsgi_pass (scgi_pass uses the value calculated based on the actual request body buffers, and therefore works correctly).
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 27 Apr 2024 18:55:50 +0300
parents 2a0a6035a1af
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
73
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
1 #!/usr/bin/perl
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
2
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
3 # (C) Maxim Dounin
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
4
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
5 # Tests for nginx ssi module.
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
6
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
7 ###############################################################################
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
8
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
9 use warnings;
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
10 use strict;
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
11
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
12 use Test::More;
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
13
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
14 BEGIN { use FindBin; chdir($FindBin::Bin); }
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
15
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
16 use lib 'lib';
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
17 use Test::Nginx;
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
18
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
19 ###############################################################################
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
20
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
21 select STDERR; $| = 1;
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
22 select STDOUT; $| = 1;
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
23
1020
196d33c2bb45 Tests: removed TODO and try_run() checks for legacy versions.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 974
diff changeset
24 my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)
1712
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
25 ->plan(30);
73
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
26
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
27 $t->write_file_expand('nginx.conf', <<'EOF');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
28
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 106
diff changeset
29 %%TEST_GLOBALS%%
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 106
diff changeset
30
249
6a0d934950bc Tests: remove extra spaces in "daemon off".
Maxim Dounin <mdounin@mdounin.ru>
parents: 224
diff changeset
31 daemon off;
73
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
32
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
33 events {
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
34 }
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
35
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
36 http {
107
1c0ec30614c6 Tests: add TEST_GLOBALS and TEST_GLOBALS_HTTP config chunks.
Maxim Dounin <mdounin@mdounin.ru>
parents: 106
diff changeset
37 %%TEST_GLOBALS_HTTP%%
73
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
38
105
bb5b5e69b45e Tests: empty cached subrequests shouldn't cause alerts.
Maxim Dounin <mdounin@mdounin.ru>
parents: 102
diff changeset
39 proxy_cache_path %%TESTDIR%%/cache levels=1:2
503
071e8941e3bf Tests: reduce shared memory zone sizes.
Maxim Dounin <mdounin@mdounin.ru>
parents: 502
diff changeset
40 keys_zone=NAME:1m;
105
bb5b5e69b45e Tests: empty cached subrequests shouldn't cause alerts.
Maxim Dounin <mdounin@mdounin.ru>
parents: 102
diff changeset
41
73
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
42 server {
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
43 listen 127.0.0.1:8080;
73
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
44 server_name localhost;
129
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
45
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
46 if ($args = "found") {
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
47 return 204;
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
48 }
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
49
91
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
50 location / {
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
51 ssi on;
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
52 }
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
53 location /proxy/ {
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
54 ssi on;
974
882267679006 Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents: 952
diff changeset
55 proxy_pass http://127.0.0.1:8080/local/;
91
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
56 }
105
bb5b5e69b45e Tests: empty cached subrequests shouldn't cause alerts.
Maxim Dounin <mdounin@mdounin.ru>
parents: 102
diff changeset
57 location /cache/ {
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:8080/local/;
105
bb5b5e69b45e Tests: empty cached subrequests shouldn't cause alerts.
Maxim Dounin <mdounin@mdounin.ru>
parents: 102
diff changeset
59 proxy_cache NAME;
bb5b5e69b45e Tests: empty cached subrequests shouldn't cause alerts.
Maxim Dounin <mdounin@mdounin.ru>
parents: 102
diff changeset
60 proxy_cache_valid 200 1h;
bb5b5e69b45e Tests: empty cached subrequests shouldn't cause alerts.
Maxim Dounin <mdounin@mdounin.ru>
parents: 102
diff changeset
61 }
91
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
62 location /local/ {
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
63 ssi off;
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
64 alias %%TESTDIR%%/;
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
65 }
502
134ea15d7473 Tests: SSI test with "postpone_output 0" (ticket #132).
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
66 location = /test-empty-postpone.html {
134ea15d7473 Tests: SSI test with "postpone_output 0" (ticket #132).
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
67 ssi on;
134ea15d7473 Tests: SSI test with "postpone_output 0" (ticket #132).
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
68 postpone_output 0;
134ea15d7473 Tests: SSI test with "postpone_output 0" (ticket #132).
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
69 }
369
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
70 location /var {
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
71 ssi on;
573
517cde5075d8 Tests: improved time zone name checks for $date_gmt in ssi.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 568
diff changeset
72 add_header X-Var x${date_gmt}x;
369
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
73 }
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
74 location /var_noformat {
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
75 ssi on;
573
517cde5075d8 Tests: improved time zone name checks for $date_gmt in ssi.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 568
diff changeset
76 add_header X-Var x${date_gmt}x;
369
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
77 return 200;
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
78 }
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
79 location /var_nossi {
573
517cde5075d8 Tests: improved time zone name checks for $date_gmt in ssi.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 568
diff changeset
80 add_header X-Var x${date_gmt}x;
369
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
81 return 200;
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
82 }
73
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
83 }
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
84 }
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
85
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
86 EOF
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
87
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
88 $t->write_file('test1.html', 'X<!--#echo var="arg_test" -->X');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
89 $t->write_file('test2.html',
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
90 'X<!--#include virtual="/test1.html?test=test" -->X');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
91 $t->write_file('test3.html',
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
92 'X<!--#set var="blah" value="test" --><!--#echo var="blah" -->X');
1712
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
93 $t->write_file('test4-echo-none.html',
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
94 'X<!--#set var="blah" value="<test>" -->'
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
95 . '<!--#echo var="blah" encoding="none" -->X');
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
96 $t->write_file('test5-echo-url.html',
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
97 'X<!--#set var="blah" value="<test>" -->'
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
98 . '<!--#echo var="blah" encoding="url" -->X');
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
99 $t->write_file('test6-echo-entity.html',
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
100 'X<!--#set var="blah" value="<test>" -->'
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
101 . '<!--#echo var="blah" encoding="entity" -->X');
129
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
102 $t->write_file('test-args-rewrite.html',
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
103 'X<!--#include virtual="/check?found" -->X');
102
9f723d3ba52d Tests: tests for empty static subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 98
diff changeset
104 $t->write_file('test-empty1.html', 'X<!--#include virtual="/empty.html" -->X');
9f723d3ba52d Tests: tests for empty static subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 98
diff changeset
105 $t->write_file('test-empty2.html',
9f723d3ba52d Tests: tests for empty static subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 98
diff changeset
106 'X<!--#include virtual="/local/empty.html" -->X');
105
bb5b5e69b45e Tests: empty cached subrequests shouldn't cause alerts.
Maxim Dounin <mdounin@mdounin.ru>
parents: 102
diff changeset
107 $t->write_file('test-empty3.html',
bb5b5e69b45e Tests: empty cached subrequests shouldn't cause alerts.
Maxim Dounin <mdounin@mdounin.ru>
parents: 102
diff changeset
108 'X<!--#include virtual="/cache/empty.html" -->X');
502
134ea15d7473 Tests: SSI test with "postpone_output 0" (ticket #132).
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
109 $t->write_file('test-empty-postpone.html',
134ea15d7473 Tests: SSI test with "postpone_output 0" (ticket #132).
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
110 'X<!--#include virtual="/proxy/empty.html" -->X');
102
9f723d3ba52d Tests: tests for empty static subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 98
diff changeset
111 $t->write_file('empty.html', '');
73
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
112
574
2cd00179f4b2 Tests: has_feature() introduced in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 573
diff changeset
113 $t->write_file('unescape.html?', 'SEE-THIS') unless $^O eq 'MSWin32';
367
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
114 $t->write_file('unescape1.html',
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
115 'X<!--#include virtual="/tes%741.html?test=test" -->X');
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
116 $t->write_file('unescape2.html',
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
117 'X<!--#include virtual="/unescape.html%3f" -->X');
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
118 $t->write_file('unescape3.html',
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
119 'X<!--#include virtual="/test1.html%3ftest=test" -->X');
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
120
369
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
121 $t->write_file('var_format.html',
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
122 'x<!--#if expr="$arg_custom" -->'
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
123 . '<!--#config timefmt="%A, %H:%M:%S" -->'
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
124 . '<!--#set var="v" value="$date_gmt" -->'
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
125 . '<!--#echo var="v" -->'
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
126 . '<!--#else -->'
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
127 . '<!--#set var="v" value="$date_gmt" -->'
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
128 . '<!--#echo var="v" -->'
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
129 . '<!--#endif -->x');
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
130
73
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
131 $t->run();
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
132
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
133 ###############################################################################
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
134
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
135 like(http_get('/test1.html'), qr/^X\(none\)X$/m, 'echo no argument');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
136 like(http_get('/test1.html?test='), qr/^XX$/m, 'empty argument');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
137 like(http_get('/test1.html?test=test'), qr/^XtestX$/m, 'argument');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
138 like(http_get('/test1.html?test=test&a=b'), qr/^XtestX$/m, 'argument 2');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
139 like(http_get('/test1.html?a=b&test=test'), qr/^XtestX$/m, 'argument 3');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
140 like(http_get('/test1.html?a=b&test=test&d=c'), qr/^XtestX$/m, 'argument 4');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
141 like(http_get('/test1.html?atest=a&testb=b&ctestc=c&test=test'), qr/^XtestX$/m,
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
142 'argument 5');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
143
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
144 like(http_get('/test2.html'), qr/^XXtestXX$/m, 'argument via include');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
145
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
146 like(http_get('/test3.html'), qr/^XtestX$/m, 'set');
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
147
1712
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
148 like(http_get('/test4-echo-none.html'), qr/^X<test>X$/m,
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
149 'echo encoding none');
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
150
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
151 like(http_get('/test5-echo-url.html'), qr/^X%3Ctest%3EX$/m,
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
152 'echo encoding url');
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
153
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
154 like(http_get('/test6-echo-entity.html'), qr/^X&lt;test&gt;X$/m,
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
155 'echo encoding entity');
0605f9a6f7b0 Tests: added ssi echo encoding tests.
Sergey Kandaurov <pluknet@nginx.com>
parents: 1020
diff changeset
156
129
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
157 # args should be in subrequest even if original request has no args and that
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
158 # was queried somehow (e.g. by server rewrites)
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
159
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
160 like(http_get('/test-args-rewrite.html'), qr/^XX$/m, 'args only subrequest');
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
161
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
162 like(http_get('/test-args-rewrite.html?wasargs'), qr/^XX$/m,
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
163 'args was in main request');
adbf104668b6 Tests: add test for $args in subrequest only.
Maxim Dounin <mdounin@mdounin.ru>
parents: 121
diff changeset
164
91
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
165 # Last-Modified and Accept-Ranges headers should be cleared
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
166
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
167 unlike(http_get('/test1.html'), qr/Last-Modified|Accept-Ranges/im,
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
168 'cleared headers');
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
169 unlike(http_get('/proxy/test1.html'), qr/Last-Modified|Accept-Ranges/im,
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
170 'cleared headers from proxy');
ec89d4d65bef Tests: Last-Modified and Accept-Ranges should be cleared on ssi.
Maxim Dounin <mdounin@mdounin.ru>
parents: 73
diff changeset
171
502
134ea15d7473 Tests: SSI test with "postpone_output 0" (ticket #132).
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
172 # empty subrequests
134ea15d7473 Tests: SSI test with "postpone_output 0" (ticket #132).
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
173
102
9f723d3ba52d Tests: tests for empty static subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 98
diff changeset
174 like(http_get('/test-empty1.html'), qr/HTTP/, 'empty with ssi');
9f723d3ba52d Tests: tests for empty static subrequests.
Maxim Dounin <mdounin@mdounin.ru>
parents: 98
diff changeset
175 like(http_get('/test-empty2.html'), qr/HTTP/, 'empty without ssi');
105
bb5b5e69b45e Tests: empty cached subrequests shouldn't cause alerts.
Maxim Dounin <mdounin@mdounin.ru>
parents: 102
diff changeset
176 like(http_get('/test-empty3.html'), qr/HTTP/, 'empty with proxy');
bb5b5e69b45e Tests: empty cached subrequests shouldn't cause alerts.
Maxim Dounin <mdounin@mdounin.ru>
parents: 102
diff changeset
177 like(http_get('/test-empty3.html'), qr/HTTP/, 'empty with proxy cached');
bb5b5e69b45e Tests: empty cached subrequests shouldn't cause alerts.
Maxim Dounin <mdounin@mdounin.ru>
parents: 102
diff changeset
178
502
134ea15d7473 Tests: SSI test with "postpone_output 0" (ticket #132).
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
179 like(http_get('/test-empty-postpone.html'), qr/HTTP.*XX/ms,
134ea15d7473 Tests: SSI test with "postpone_output 0" (ticket #132).
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
180 'empty with postpone_output 0');
134ea15d7473 Tests: SSI test with "postpone_output 0" (ticket #132).
Maxim Dounin <mdounin@mdounin.ru>
parents: 397
diff changeset
181
367
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
182 # handling of escaped URIs
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
183
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
184 like(http_get('/unescape1.html'), qr/^XXtestXX$/m, 'escaped in path');
574
2cd00179f4b2 Tests: has_feature() introduced in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 573
diff changeset
185
2cd00179f4b2 Tests: has_feature() introduced in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 573
diff changeset
186 SKIP: {
2cd00179f4b2 Tests: has_feature() introduced in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 573
diff changeset
187 skip 'incorrect filename on win32', 2 if $^O eq 'MSWin32';
2cd00179f4b2 Tests: has_feature() introduced in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 573
diff changeset
188
367
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
189 like(http_get('/unescape2.html'), qr/^XSEE-THISX$/m,
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
190 'escaped question in path');
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
191 like(http_get('/unescape3.html'), qr/404 Not Found/,
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
192 'escaped query separator');
0726521e42f3 Tests: added tests for escaped and unsafe URIs.
Sergey Kandaurov <pluknet@nginx.com>
parents: 249
diff changeset
193
574
2cd00179f4b2 Tests: has_feature() introduced in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 573
diff changeset
194 }
2cd00179f4b2 Tests: has_feature() introduced in Test::Nginx.
Sergey Kandaurov <pluknet@nginx.com>
parents: 573
diff changeset
195
369
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
196 # handling of embedded date variables
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
197
617
35832048546e Tests: respected custom locales when parsing $date_gmt in ssi.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 593
diff changeset
198 my $re_date_gmt = qr/X-Var: x.+, \d\d-.+-\d{4} \d\d:\d\d:\d\d .+x/;
369
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
199
573
517cde5075d8 Tests: improved time zone name checks for $date_gmt in ssi.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 568
diff changeset
200 like(http_get('/var_nossi.html'), $re_date_gmt, 'no ssi');
517cde5075d8 Tests: improved time zone name checks for $date_gmt in ssi.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 568
diff changeset
201 like(http_get('/var_noformat.html'), $re_date_gmt, 'no format');
517cde5075d8 Tests: improved time zone name checks for $date_gmt in ssi.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 568
diff changeset
202
517cde5075d8 Tests: improved time zone name checks for $date_gmt in ssi.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 568
diff changeset
203 like(http_get('/var_format.html?custom=1'), $re_date_gmt, 'custom header');
517cde5075d8 Tests: improved time zone name checks for $date_gmt in ssi.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 568
diff changeset
204 like(http_get('/var_format.html'), $re_date_gmt, 'default header');
369
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
205
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
206 like(http_get('/var_format.html?custom=1'),
617
35832048546e Tests: respected custom locales when parsing $date_gmt in ssi.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 593
diff changeset
207 qr/x.+, \d\d:\d\d:\d\dx/, 'custom ssi');
369
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
208 like(http_get('/var_format.html'),
617
35832048546e Tests: respected custom locales when parsing $date_gmt in ssi.t.
Sergey Kandaurov <pluknet@nginx.com>
parents: 593
diff changeset
209 qr/x.+, \d\d-.+-\d{4} \d\d:\d\d:\d\d .+x/, 'default ssi');
369
4ac3588485f5 Tests: added tests for embedded ssi variable.
Sergey Kandaurov <pluknet@nginx.com>
parents: 367
diff changeset
210
73
c8ba98ad0570 Tests: some very basic ssi tests.
Maxim Dounin <mdounin@mdounin.ru>
parents:
diff changeset
211 ###############################################################################