From: Eric Wong Date: Sat, 21 Mar 2020 02:03:47 +0000 (+0000) Subject: extmsg: use WwwResponse::oneshot X-Git-Tag: v1.4.0~59 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=d27de5b3df43f41c4e8f3b1cbad79b2436d2a549 extmsg: use WwwResponse::oneshot No reason to use the ->getline interface for small responses. --- diff --git a/lib/PublicInbox/ExtMsg.pm b/lib/PublicInbox/ExtMsg.pm index 4d753a7e..a14eddf6 100644 --- a/lib/PublicInbox/ExtMsg.pm +++ b/lib/PublicInbox/ExtMsg.pm @@ -159,7 +159,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 { @@ -197,7 +197,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;