Mercurial > hg > nginx-tests
comparison ssi-include-big.t @ 5:4d75bdb05ecf
Tests: some generic code and ssi tests.
Move generic code to _common.pm and add test for ssi big includes.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Sun, 07 Sep 2008 05:00:28 +0400 |
parents | |
children | 8813a78ab8b5 |
comparison
equal
deleted
inserted
replaced
4:6c41dbb2954f | 5:4d75bdb05ecf |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 # (C) Maxim Dounin | |
4 | |
5 # Tests for nginx ssi bug with big includes. | |
6 | |
7 ############################################################################### | |
8 | |
9 use warnings; | |
10 use strict; | |
11 | |
12 use Test::More tests => 3; | |
13 | |
14 use _common; | |
15 use Compress::Zlib; | |
16 | |
17 ############################################################################### | |
18 | |
19 select STDERR; $| = 1; | |
20 select STDOUT; $| = 1; | |
21 | |
22 start_nginx('ssi-include-big.conf'); | |
23 | |
24 write_file('c1.html', 'X' x 1023); | |
25 write_file('c2.html', 'X' x 1024); | |
26 write_file('c3.html', 'X' x 1025); | |
27 write_file('test1.html', '<!--#include virtual="/proxy/blah" -->' . "\n" | |
28 . '<!--#include virtual="/c1.html" -->'); | |
29 write_file('test2.html', '<!--#include virtual="/proxy/blah" -->' . "\n" | |
30 . '<!--#include virtual="/c2.html" -->'); | |
31 write_file('test3.html', '<!--#include virtual="/proxy/blah" -->' . "\n" | |
32 . '<!--#include virtual="/c3.html" -->'); | |
33 | |
34 ############################################################################### | |
35 | |
36 my $t1 = http_gzip_request('/test1.html'); | |
37 like($t1, qr/X{1023}/, 'small included file (less than output_buffers)'); | |
38 | |
39 my $t2 = http_gzip_request('/test2.html'); | |
40 like($t2, qr/X{1024}/, 'small included file (equal to output_buffers)'); | |
41 | |
42 my $t3 = http_gzip_request('/test3.html'); | |
43 like($t3, qr/X{1025}/, 'big included file (more than output_buffers)'); | |
44 | |
45 ############################################################################### | |
46 | |
47 sub http_gzip_request { | |
48 my ($url) = @_; | |
49 return `GET -t 1 -H 'Accept-Encoding: gzip' http://localhost:8080$url | gunzip -c`; | |
50 =pod | |
51 | |
52 my $r = http(<<EOF); | |
53 GET $url HTTP/1.0 | |
54 Host: localhost | |
55 Connection: close | |
56 Accept-Encoding: gzip | |
57 | |
58 EOF | |
59 return undef unless defined $r; | |
60 return undef unless $r =~ m/\x0d\x0a\x0d\x0a(.*)/ms; | |
61 return Compress::Zlib::memGunzip(my $b = $1); | |
62 =cut | |
63 } | |
64 | |
65 sub write_file { | |
66 my ($name, $content) = @_; | |
67 | |
68 open F, '>' . $_common::testdir . '/' . $name | |
69 or die "Can't create $name: $!"; | |
70 print F $content; | |
71 close F; | |
72 } | |
73 | |
74 ############################################################################### |