mirror of
https://github.com/h2o/h2o.git
synced 2025-04-20 13:11:35 +08:00
add file.custom-handler tests
This commit is contained in:
parent
cb1c5134ca
commit
a5c3c68a7d
82
t/50file-custom-handler.t
Normal file
82
t/50file-custom-handler.t
Normal file
@ -0,0 +1,82 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More;
|
||||
use t::Util;
|
||||
|
||||
plan skip_all => 'curl not found'
|
||||
unless prog_exists('curl');
|
||||
|
||||
subtest 'cgi file' => sub {
|
||||
eval q{use CGI; 1}
|
||||
or plan skip_all => 'CGI.pm not found';
|
||||
|
||||
# spawn h2o
|
||||
my $server = spawn_h2o(<< "EOT");
|
||||
file.custom-handler:
|
||||
extension: .cgi
|
||||
fastcgi.spawn: "exec \$H2O_ROOT/share/h2o/fastcgi-cgi"
|
||||
hosts:
|
||||
default:
|
||||
paths:
|
||||
/robots.txt:
|
||||
file.file: @{[DOC_ROOT]}/hello.cgi
|
||||
EOT
|
||||
run_with_curl($server, sub {
|
||||
my ($proto, $port, $cmd) = @_;
|
||||
my $resp = `$cmd --silent $proto://127.0.0.1:$port/robots.txt?name=Tobor`;
|
||||
is $resp, "Hello Tobor";
|
||||
});
|
||||
};
|
||||
|
||||
subtest 'cgi file with no extension' => sub {
|
||||
eval q{use CGI; 1}
|
||||
or plan skip_all => 'CGI.pm not found';
|
||||
|
||||
# spawn h2o
|
||||
my $server = spawn_h2o(<< "EOT");
|
||||
file.custom-handler:
|
||||
extension: default
|
||||
fastcgi.spawn: "exec \$H2O_ROOT/share/h2o/fastcgi-cgi"
|
||||
hosts:
|
||||
default:
|
||||
paths:
|
||||
/robots.txt:
|
||||
file.file: @{[DOC_ROOT]}/noextcgi
|
||||
EOT
|
||||
run_with_curl($server, sub {
|
||||
my ($proto, $port, $cmd) = @_;
|
||||
my $resp = `$cmd --silent $proto://127.0.0.1:$port/robots.txt?name=Tobor`;
|
||||
is $resp, "Hello Tobor";
|
||||
});
|
||||
};
|
||||
|
||||
subtest 'directory containing cgi files' => sub {
|
||||
eval q{use CGI; 1}
|
||||
or plan skip_all => 'CGI.pm not found';
|
||||
|
||||
# spawn h2o
|
||||
my $server = spawn_h2o(<< "EOT");
|
||||
file.custom-handler:
|
||||
extension: ["default", ".cgi"]
|
||||
fastcgi.spawn: "exec \$H2O_ROOT/share/h2o/fastcgi-cgi"
|
||||
hosts:
|
||||
default:
|
||||
paths:
|
||||
/:
|
||||
file.dir: @{[DOC_ROOT]}
|
||||
EOT
|
||||
run_with_curl($server, sub {
|
||||
my ($proto, $port, $cmd) = @_;
|
||||
my $resp = `$cmd --silent $proto://127.0.0.1:$port/hello.cgi?name=Tobor`;
|
||||
is $resp, "Hello Tobor";
|
||||
});
|
||||
|
||||
run_with_curl($server, sub {
|
||||
my ($proto, $port, $cmd) = @_;
|
||||
my $resp = `$cmd --silent $proto://127.0.0.1:$port/noextcgi?name=Tobor`;
|
||||
is $resp, "Hello Tobor";
|
||||
});
|
||||
};
|
||||
|
||||
done_testing;
|
||||
|
@ -29,48 +29,4 @@ EOT
|
||||
});
|
||||
};
|
||||
|
||||
subtest 'dynamic' => sub {
|
||||
eval q{use CGI; 1}
|
||||
or plan skip_all => 'CGI.pm not found';
|
||||
|
||||
# spawn h2o
|
||||
my $server = spawn_h2o(<< "EOT");
|
||||
file.custom-handler:
|
||||
extension: .cgi
|
||||
fastcgi.spawn: "exec \$H2O_ROOT/share/h2o/fastcgi-cgi"
|
||||
hosts:
|
||||
default:
|
||||
paths:
|
||||
/robots.txt:
|
||||
file.file: @{[DOC_ROOT]}/hello.cgi
|
||||
EOT
|
||||
run_with_curl($server, sub {
|
||||
my ($proto, $port, $cmd) = @_;
|
||||
my $resp = `$cmd --silent $proto://127.0.0.1:$port/robots.txt?name=Tobor`;
|
||||
is $resp, "Hello Tobor";
|
||||
});
|
||||
};
|
||||
|
||||
subtest 'dynamic with default type' => sub {
|
||||
eval q{use CGI; 1}
|
||||
or plan skip_all => 'CGI.pm not found';
|
||||
|
||||
# spawn h2o
|
||||
my $server = spawn_h2o(<< "EOT");
|
||||
file.custom-handler:
|
||||
extension: default
|
||||
fastcgi.spawn: "exec \$H2O_ROOT/share/h2o/fastcgi-cgi"
|
||||
hosts:
|
||||
default:
|
||||
paths:
|
||||
/robots.txt:
|
||||
file.file: @{[DOC_ROOT]}/noextcgi
|
||||
EOT
|
||||
run_with_curl($server, sub {
|
||||
my ($proto, $port, $cmd) = @_;
|
||||
my $resp = `$cmd --silent $proto://127.0.0.1:$port/robots.txt?name=Tobor`;
|
||||
is $resp, "Hello Tobor";
|
||||
});
|
||||
};
|
||||
|
||||
done_testing;
|
||||
|
Loading…
x
Reference in New Issue
Block a user