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-ASN: 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 F18961F61F for ; Sat, 21 Mar 2020 02:03:54 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/11] extmsg: use WwwResponse::oneshot Date: Sat, 21 Mar 2020 02:03:47 +0000 Message-Id: <20200321020354.9056-5-e@yhbt.net> In-Reply-To: <20200321020354.9056-1-e@yhbt.net> References: <20200321020354.9056-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: No reason to use the ->getline interface for small responses. --- lib/PublicInbox/ExtMsg.pm | 4 ++-- lib/PublicInbox/WwwStream.pm | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm index 44884ad2..74a95cf9 100644 --- a/lib/PublicInbox/ExtMsg.pm +++ b/lib/PublicInbox/ExtMsg.pm @@ -158,7 +158,7 @@ sub ext_msg { $ctx->{-html_tip} = $s .= ''; $ctx->{-title_html} = $title; $ctx->{-upfx} = '../'; - PublicInbox::WwwStream->response($ctx, $code); + PublicInbox::WwwStream::oneshot($ctx, $code); } sub ext_urls { @@ -196,7 +196,7 @@ sub exact { qq($u$html/\n) } @$found), $ext_urls, ''); - PublicInbox::WwwStream->response($ctx, $code); + PublicInbox::WwwStream::oneshot($ctx, $code); } 1; diff --git a/lib/PublicInbox/WwwStream.pm b/lib/PublicInbox/WwwStream.pm index 2dd8b157..fceef745 100644 --- a/lib/PublicInbox/WwwStream.pm +++ b/lib/PublicInbox/WwwStream.pm @@ -28,7 +28,7 @@ sub new { bless { nr => 0, - cb => $cb || \&close, + cb => $cb, ctx => $ctx, base_url => base_url($ctx), }, $class; @@ -175,8 +175,9 @@ sub oneshot { ctx => $ctx, base_url => base_url($ctx), }, __PACKAGE__; - [ $code, [ 'Content-Type', 'text/html; charset=UTF-8' ], - [ _html_top($self), $$strref, _html_end($self) ] ] + [ $code, [ 'Content-Type', 'text/html; charset=UTF-8' ], [ + _html_top($self), $strref ? $$strref : (), _html_end($self) + ] ] } 1;