view ssi-include-big.t @ 35:7bf0e8a1d66c

Tests: always define temp paths. This is required since nginx tries to create them at startup (and fails if it can't).
author Maxim Dounin <mdounin@mdounin.ru>
date Thu, 16 Oct 2008 19:16:46 +0400
parents 18296293d18a
children fc205d0e052d
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;

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

use lib 'lib';
use Test::Nginx;

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

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

my $t = Test::Nginx->new()->has('rewrite')->plan(3);

$t->write_file_expand('nginx.conf', <<'EOF');

master_process off;
daemon         off;

events {
    worker_connections  1024;
}

http {
    access_log    off;
    root          %%TESTDIR%%;

    client_body_temp_path  %%TESTDIR%%/client_body_temp;
    fastcgi_temp_path      %%TESTDIR%%/fastcgi_temp;
    proxy_temp_path        %%TESTDIR%%/proxy_temp;

    output_buffers  2 512;
    ssi on;
    gzip on;

    server {
        listen       localhost:8080;
        server_name  localhost;

        location /proxy/ {
            proxy_pass http://localhost:8080/local/;
        }
        location = /local/blah {
            return 204;
        }
    }
}

EOF

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

$t->run();

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

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)');

TODO: {
local $TODO = 'not fixed yet, patch under review';

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.1
Host: localhost
Connection: close
Accept-Encoding: gzip

EOF
}

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