mirror of
https://github.com/cesanta/mongoose.git
synced 2025-08-06 13:37:34 +08:00
test for immediate CGI output forward
This commit is contained in:
parent
da21192b10
commit
3cd16d7266
16
test/test.pl
16
test/test.pl
@ -50,7 +50,7 @@ sub get_num_of_log_entries {
|
|||||||
|
|
||||||
# Send the request to the 127.0.0.1:$port and return the reply
|
# Send the request to the 127.0.0.1:$port and return the reply
|
||||||
sub req {
|
sub req {
|
||||||
my ($request, $inc) = @_;
|
my ($request, $inc, $timeout) = @_;
|
||||||
my $sock = IO::Socket::INET->new(Proto=>"tcp",
|
my $sock = IO::Socket::INET->new(Proto=>"tcp",
|
||||||
PeerAddr=>'127.0.0.1', PeerPort=>$port);
|
PeerAddr=>'127.0.0.1', PeerPort=>$port);
|
||||||
fail("Cannot connect: $!") unless $sock;
|
fail("Cannot connect: $!") unless $sock;
|
||||||
@ -59,8 +59,14 @@ sub req {
|
|||||||
last unless print $sock $byte;
|
last unless print $sock $byte;
|
||||||
select undef, undef, undef, .001 if length($request) < 256;
|
select undef, undef, undef, .001 if length($request) < 256;
|
||||||
}
|
}
|
||||||
my @lines = <$sock>;
|
my $out = '';
|
||||||
my $out = join '', @lines;
|
eval {
|
||||||
|
alarm $timeout if $timeout;
|
||||||
|
foreach (<$sock>) {
|
||||||
|
$out .= $_;
|
||||||
|
}
|
||||||
|
alarm 0;
|
||||||
|
};
|
||||||
close $sock;
|
close $sock;
|
||||||
|
|
||||||
$num_requests += defined($inc) ? $inc : 1;
|
$num_requests += defined($inc) ? $inc : 1;
|
||||||
@ -129,6 +135,7 @@ sub kill_spawned_child {
|
|||||||
|
|
||||||
unlink @files_to_delete;
|
unlink @files_to_delete;
|
||||||
$SIG{PIPE} = 'IGNORE';
|
$SIG{PIPE} = 'IGNORE';
|
||||||
|
$SIG{ALRM} = sub { die "timeout\n" };
|
||||||
#local $| =1;
|
#local $| =1;
|
||||||
|
|
||||||
# Make sure we export only symbols that start with "mg_", and keep local
|
# Make sure we export only symbols that start with "mg_", and keep local
|
||||||
@ -218,6 +225,9 @@ o("GET /ta/x/ HTTP/1.0\n\n", "SCRIPT_NAME=/ta/x/index.cgi",
|
|||||||
# 'HTTP/1.1 200.+keep-alive.+HTTP/1.1 200.+close',
|
# 'HTTP/1.1 200.+keep-alive.+HTTP/1.1 200.+close',
|
||||||
# 'Request pipelining', 2);
|
# 'Request pipelining', 2);
|
||||||
|
|
||||||
|
fail('Slow CGI output forward ') unless
|
||||||
|
req("GET /timeout.cgi HTTP/1.0\r\n\r\n", 1, 1) =~ /Some data/gs;
|
||||||
|
|
||||||
my $mime_types = {
|
my $mime_types = {
|
||||||
html => 'text/html',
|
html => 'text/html',
|
||||||
htm => 'text/html',
|
htm => 'text/html',
|
||||||
|
Loading…
Reference in New Issue
Block a user