From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 7ACB61F8E0 for ; Sun, 5 Jul 2020 23:28:01 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 06/43] www: need: use WwwStream::html_oneshot Date: Sun, 5 Jul 2020 23:27:22 +0000 Message-Id: <20200705232759.3161-7-e@yhbt.net> In-Reply-To: <20200705232759.3161-1-e@yhbt.net> References: <20200705232759.3161-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It'll give us a nicer HTML header and footer. --- lib/PublicInbox/WWW.pm | 9 ++++----- t/plack.t | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/WWW.pm b/lib/PublicInbox/WWW.pm index 289d0ce48..e4ad515a4 100644 --- a/lib/PublicInbox/WWW.pm +++ b/lib/PublicInbox/WWW.pm @@ -322,12 +322,11 @@ sub get_altid_dump { sub need { my ($ctx, $extra) = @_; - my $msg = <$extra not available for this -public-inbox
$extra is not available for this public-inbox
-Return to index
+ require PublicInbox::WwwStream; + PublicInbox::WwwStream::html_oneshot($ctx, 501, \<$extra is not available for this public-inbox +Return to index EOF - [ 501, [ 'Content-Type' => 'text/html; charset=UTF-8' ], [ $msg ] ]; } # /$INBOX/$MESSAGE_ID/t.mbox -> thread as mbox diff --git a/t/plack.t b/t/plack.t index 37a6b3948..4b830a21e 100644 --- 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