+ test_psgi($app, sub {
+ my ($cb) = @_;
+ my $path = '/blah@example.com/';
+ my $res = $cb->(GET($pfx . $path));
+ is(200, $res->code, "success for $path");
+ like($res->content, qr!<title>hihi - Me</title>!,
+ "HTML returned");
+
+ $path .= 'f/';
+ $res = $cb->(GET($pfx . $path));
+ is(301, $res->code, "redirect for $path");
+ my $location = $res->header('Location');
+ like($location, qr!/blah\@example\.com/\z!,
+ '/$MESSAGE_ID/f/ redirected to /$MESSAGE_ID/');
+ });
+
+ test_psgi($app, sub {
+ my ($cb) = @_;
+ my $res = $cb->(GET($pfx . '/blah@example.com/raw'));
+ is(200, $res->code, 'success response received for /*/raw');
+ like($res->content, qr!^From !sm, "mbox returned");
+ });
+
+ # legacy redirects
+ foreach my $t (qw(m f)) {
+ test_psgi($app, sub {
+ my ($cb) = @_;
+ my $res = $cb->(GET($pfx . "/$t/blah\@example.com.txt"));
+ is(301, $res->code, "redirect for old $t .txt link");
+ my $location = $res->header('Location');
+ like($location, qr!/blah\@example\.com/raw\z!,
+ ".txt redirected to /raw");
+ });
+ }