]> Sergey Matveev's repositories - public-inbox.git/commitdiff
www: need: use WwwStream::html_oneshot
authorEric Wong <e@yhbt.net>
Sun, 5 Jul 2020 23:27:22 +0000 (23:27 +0000)
committerEric Wong <e@yhbt.net>
Mon, 6 Jul 2020 20:01:15 +0000 (20:01 +0000)
It'll give us a nicer HTML header and footer.

lib/PublicInbox/WWW.pm
t/plack.t

index 289d0ce48e255a9bf4e315164ed380da284f2fe4..e4ad515a4d341d03ef5014f18d0a783c44c8fb31 100644 (file)
@@ -322,12 +322,11 @@ sub get_altid_dump {
 
 sub need {
        my ($ctx, $extra) = @_;
-       my $msg = <<EOF;
-<html><head><title>$extra not available for this
-public-inbox</title><body><pre>$extra is not available for this public-inbox
-<a href="../">Return to index</a></pre></body></html>
+       require PublicInbox::WwwStream;
+       PublicInbox::WwwStream::html_oneshot($ctx, 501, \<<EOF);
+<pre>$extra is not available for this public-inbox
+<a\nhref="../">Return to index</a></pre>
 EOF
-       [ 501, [ 'Content-Type' => 'text/html; charset=UTF-8' ], [ $msg ] ];
 }
 
 # /$INBOX/$MESSAGE_ID/t.mbox           -> thread as mbox
index 37a6b39486e06ea1e4fc575893c3de96e09bc7f1..4b830a21e35c72b3bf1712d0150ae73b8483a144 100644 (file)
--- a/t/plack.t
+++ b/t/plack.t
@@ -209,6 +209,10 @@ test_psgi($app, sub {
        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");
+
+       $res = $cb->(GET($pfx . '/blah@example.com/t.mbox.gz'));
+       is(501, $res->code, '501 when overview missing');
+       like($res->content, qr!\bOverview\b!, 'overview omission noted');
 });
 
 # legacy redirects