]> Sergey Matveev's repositories - public-inbox.git/commitdiff
extmsg: use WwwResponse::oneshot
authorEric Wong <e@yhbt.net>
Sat, 21 Mar 2020 02:03:47 +0000 (02:03 +0000)
committerEric Wong <e@yhbt.net>
Wed, 25 Mar 2020 01:48:35 +0000 (01:48 +0000)
No reason to use the ->getline interface for small responses.

lib/PublicInbox/ExtMsg.pm
lib/PublicInbox/WwwStream.pm

index 4d753a7e8f00feca8089d0e8f6caa469bcc6dc0b..a14eddf6cd8ce1651f357a50b35e5bae7e12f753 100644 (file)
@@ -159,7 +159,7 @@ sub ext_msg {
        $ctx->{-html_tip} = $s .= '</pre>';
        $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(<a\nhref="$u$href/">$u$html/</a>\n)
                                } @$found),
                        $ext_urls, '</pre>');
-       PublicInbox::WwwStream->response($ctx, $code);
+       PublicInbox::WwwStream::oneshot($ctx, $code);
 }
 
 1;
index 2dd8b157ddc7334d49a95fdd97fc7ea47563f59c..fceef745d0c4ec2291448a2ff131a68880030530 100644 (file)
@@ -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;