use constant CGI => "blib/script/public-inbox.cgi";
my $mda = "blib/script/public-inbox-mda";
my $index = "blib/script/public-inbox-index";
-my $tmpdir = tempdir(CLEANUP => 1);
+my $tmpdir = tempdir('pi-cgi-XXXXXX', TMPDIR => 1, CLEANUP => 1);
my $home = "$tmpdir/pi-home";
my $pi_home = "$home/.public-inbox";
my $pi_config = "$pi_home/config";
like($res->{head}, qr/Status:\s*404/i, "index returns 404");
}
+# dumb HTTP support
+{
+ local $ENV{HOME} = $home;
+ my $path = "/test/info/refs";
+ my $res = cgi_run($path);
+ like($res->{head}, qr/Status:\s*200/i, "info/refs readable");
+ my $orig = $res->{body};
+
+ local $ENV{HTTP_RANGE} = 'bytes=5-10';
+ $res = cgi_run($path);
+ like($res->{head}, qr/Status:\s*206/i, "info/refs partial OK");
+ is($res->{body}, substr($orig, 5, 6), 'partial body OK');
+
+ local $ENV{HTTP_RANGE} = 'bytes=5-';
+ $res = cgi_run($path);
+ like($res->{head}, qr/Status:\s*206/i, "info/refs partial past end OK");
+ is($res->{body}, substr($orig, 5), 'partial body OK past end');
+}
+
# atom feeds
{
local $ENV{HOME} = $home;
like($res->{head}, qr/Status: 300 Multiple Choices/, "mid html miss");
$res = cgi_run("/test/blahblah\@example.com/f/");
- like($res->{body}, qr/\A<html>/, "mid html");
- like($res->{head}, qr/Status: 200 OK/, "200 response");
- $res = cgi_run("/test/blahblah\@example.con/f/");
+ like($res->{head}, qr/Status: 301 Moved/, "301 response");
+ like($res->{head},
+ qr!^Location: http://[^/]+/test/blahblah%40example\.com/\r\n!ms,
+ '301 redirect location');
+ $res = cgi_run("/test/blahblah\@example.con/");
like($res->{head}, qr/Status: 300 Multiple Choices/, "mid html miss");
$res = cgi_run("/test/");