view ssi-include-big.t @ 9:f772e2a1a13f

Tests: change directory to allow runing from outside. Use FindBin to find out where tests reside and chdir() into it. This allows to use configs from the directory with tests and to use _common.pm.
author Maxim Dounin <mdounin@mdounin.ru>
date Wed, 10 Sep 2008 17:41:04 +0400
parents 8813a78ab8b5
children d19146b30334
line wrap: on
line source

#!/usr/bin/perl

# (C) Maxim Dounin

# Tests for nginx ssi bug with big includes.

###############################################################################

use warnings;
use strict;

use Test::More tests => 3;

BEGIN { use FindBin; chdir($FindBin::Bin); }

use _common;

###############################################################################

select STDERR; $| = 1;
select STDOUT; $| = 1;

start_nginx('ssi-include-big.conf');

write_file('c1.html', 'X' x 1023);
write_file('c2.html', 'X' x 1024);
write_file('c3.html', 'X' x 1025);
write_file('test1.html', '<!--#include virtual="/proxy/blah" -->' . "\n"
	. '<!--#include virtual="/c1.html" -->');
write_file('test2.html', '<!--#include virtual="/proxy/blah" -->' . "\n"
	. '<!--#include virtual="/c2.html" -->');
write_file('test3.html', '<!--#include virtual="/proxy/blah" -->' . "\n"
	. '<!--#include virtual="/c3.html" -->');

###############################################################################

my $t1 = http_gzip_request('/test1.html');
ok(defined $t1, 'small included file (less than output_buffers)');

my $t2 = http_gzip_request('/test2.html');
ok(defined $t2, 'small included file (equal to output_buffers)');

my $t3 = http_gzip_request('/test3.html');
ok(defined $t3, 'big included file (more than output_buffers)');

###############################################################################

sub http_gzip_request {
	my ($url) = @_;
	my $r = http(<<EOF);
GET $url HTTP/1.0
Host: localhost
Connection: close
Accept-Encoding: gzip

EOF
}

sub write_file {
	my ($name, $content) = @_;

	open F, '>' . $_common::testdir . '/' . $name
		or die "Can't create $name: $!";
	print F $content;
	close F;
}

###############################################################################