comparison ssi.t @ 129:adbf104668b6

Tests: add test for $args in subrequest only. It's currently not handled properly once cached as not found in main request. Reported by: Laurence Rowe
author Maxim Dounin <mdounin@mdounin.ru>
date Sat, 20 Feb 2010 05:52:56 +0300
parents 8ac1faaddd2c
children c0ae29632905
comparison
equal deleted inserted replaced
128:25047dc6ae9b 129:adbf104668b6
19 ############################################################################### 19 ###############################################################################
20 20
21 select STDERR; $| = 1; 21 select STDERR; $| = 1;
22 select STDOUT; $| = 1; 22 select STDOUT; $| = 1;
23 23
24 my $t = Test::Nginx->new()->has(qw/http ssi cache proxy/)->plan(16); 24 my $t = Test::Nginx->new()->has(qw/http ssi cache proxy rewrite/)->plan(18);
25 25
26 $t->write_file_expand('nginx.conf', <<'EOF'); 26 $t->write_file_expand('nginx.conf', <<'EOF');
27 27
28 %%TEST_GLOBALS%% 28 %%TEST_GLOBALS%%
29 29
40 keys_zone=NAME:10m; 40 keys_zone=NAME:10m;
41 41
42 server { 42 server {
43 listen 127.0.0.1:8080; 43 listen 127.0.0.1:8080;
44 server_name localhost; 44 server_name localhost;
45
46 if ($args = "found") {
47 return 204;
48 }
49
45 location / { 50 location / {
46 ssi on; 51 ssi on;
47 } 52 }
48 location /proxy/ { 53 location /proxy/ {
49 ssi on; 54 ssi on;
66 $t->write_file('test1.html', 'X<!--#echo var="arg_test" -->X'); 71 $t->write_file('test1.html', 'X<!--#echo var="arg_test" -->X');
67 $t->write_file('test2.html', 72 $t->write_file('test2.html',
68 'X<!--#include virtual="/test1.html?test=test" -->X'); 73 'X<!--#include virtual="/test1.html?test=test" -->X');
69 $t->write_file('test3.html', 74 $t->write_file('test3.html',
70 'X<!--#set var="blah" value="test" --><!--#echo var="blah" -->X'); 75 'X<!--#set var="blah" value="test" --><!--#echo var="blah" -->X');
76 $t->write_file('test-args-rewrite.html',
77 'X<!--#include virtual="/check?found" -->X');
71 $t->write_file('test-empty1.html', 'X<!--#include virtual="/empty.html" -->X'); 78 $t->write_file('test-empty1.html', 'X<!--#include virtual="/empty.html" -->X');
72 $t->write_file('test-empty2.html', 79 $t->write_file('test-empty2.html',
73 'X<!--#include virtual="/local/empty.html" -->X'); 80 'X<!--#include virtual="/local/empty.html" -->X');
74 $t->write_file('test-empty3.html', 81 $t->write_file('test-empty3.html',
75 'X<!--#include virtual="/cache/empty.html" -->X'); 82 'X<!--#include virtual="/cache/empty.html" -->X');
90 97
91 like(http_get('/test2.html'), qr/^XXtestXX$/m, 'argument via include'); 98 like(http_get('/test2.html'), qr/^XXtestXX$/m, 'argument via include');
92 99
93 like(http_get('/test3.html'), qr/^XtestX$/m, 'set'); 100 like(http_get('/test3.html'), qr/^XtestX$/m, 'set');
94 101
102 # args should be in subrequest even if original request has no args and that
103 # was queried somehow (e.g. by server rewrites)
104
105 TODO: {
106 local $TODO = 'patch under review';
107
108 like(http_get('/test-args-rewrite.html'), qr/^XX$/m, 'args only subrequest');
109
110 }
111
112 like(http_get('/test-args-rewrite.html?wasargs'), qr/^XX$/m,
113 'args was in main request');
114
95 # Last-Modified and Accept-Ranges headers should be cleared 115 # Last-Modified and Accept-Ranges headers should be cleared
96 116
97 unlike(http_get('/test1.html'), qr/Last-Modified|Accept-Ranges/im, 117 unlike(http_get('/test1.html'), qr/Last-Modified|Accept-Ranges/im,
98 'cleared headers'); 118 'cleared headers');
99 unlike(http_get('/proxy/test1.html'), qr/Last-Modified|Accept-Ranges/im, 119 unlike(http_get('/proxy/test1.html'), qr/Last-Modified|Accept-Ranges/im,