comparison msie_refresh.t @ 1257:05b2033f5377

Tests: msie_refresh generic tests.
author Sergey Kandaurov <pluknet@nginx.com>
date Wed, 06 Dec 2017 19:31:20 +0300
parents msie_refresh_ssi.t@766bcbb632ee
children
comparison
equal deleted inserted replaced
1256:fc43a3555095 1257:05b2033f5377
1 #!/usr/bin/perl
2
3 # (C) Sergey Kandaurov
4 # (C) Nginx, Inc.
5
6 # Test for msie_refresh.
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
25 my $t = Test::Nginx->new()->has(qw/http rewrite ssi/)->plan(5)
26 ->write_file_expand('nginx.conf', <<'EOF');
27
28 %%TEST_GLOBALS%%
29
30 daemon off;
31
32 events {
33 }
34
35 http {
36 %%TEST_GLOBALS_HTTP%%
37
38 server {
39 listen 127.0.0.1:8080;
40 server_name localhost;
41
42 msie_refresh on;
43
44 location / {
45 return 301 text;
46 }
47
48 location /space {
49 return 301 "space ";
50 }
51
52 location /error_page {
53 return 301;
54 error_page 301 text;
55 }
56
57 location /off {
58 msie_refresh off;
59 return 301 text;
60 }
61
62 location /ssi {
63 ssi on;
64 }
65 }
66 }
67
68 EOF
69
70 $t->write_file('ssi.html', 'X<!--#include virtual="/" -->X');
71 $t->run();
72
73 ###############################################################################
74
75 like(get('/'), qr/Refresh.*URL=text"/, 'msie refresh');
76 like(get('/space'), qr/URL=space%20"/, 'msie refresh escaped url');
77 like(get('/error_page'), qr/URL=text"/, 'msie refresh error page');
78
79 unlike(get('/off'), qr/Refresh/, 'msie refresh disabled');
80
81 unlike(get('/ssi.html'), qr/^0\x0d\x0a?\x0d\x0a?\w/m, 'only final chunk');
82
83 ###############################################################################
84
85 sub get {
86 my ($url, $extra) = @_;
87 return http(<<EOF);
88 GET $url HTTP/1.1
89 Host: localhost
90 Connection: close
91 User-Agent: MSIE foo
92
93 EOF
94 }
95
96 ###############################################################################