]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwListing.pm
get rid of unnecessary bytes::length usage
[public-inbox.git] / lib / PublicInbox / WwwListing.pm
index eb015742e86c626317b66386f2bb1d2e2ff5a829..8b54d7249aad85538789b25668d86f5dbcabdf0b 100644 (file)
@@ -5,12 +5,12 @@
 # Used by PublicInbox::WWW
 package PublicInbox::WwwListing;
 use strict;
+use v5.10.1;
 use PublicInbox::Hval qw(prurl fmt_ts ascii_html);
 use PublicInbox::Linkify;
 use PublicInbox::GzipFilter qw(gzf_maybe);
 use PublicInbox::ConfigIter;
 use PublicInbox::WwwStream;
-use bytes (); # bytes::length
 
 sub ibx_entry {
        my ($ctx, $ibx, $ce) = @_;
@@ -55,7 +55,7 @@ again:
        } elsif ($v eq 'all') {
                (qr/./, undef);
        } elsif ($v eq '404') {
-               undef;
+               (undef, undef);
        } else {
                warn <<EOF;
 `$v' is not a valid value for `$key'
@@ -90,7 +90,7 @@ sub add_misc_ibx { # MiscSearch->retry_reopen callback
                $qs = "( $qs ) AND ( $user_query )";
        }
        my $mset = $misc->mset($qs, $opt); # sorts by $MODIFIED (mtime)
-       $ctx->{-list} = [];
+       delete $ctx->{-list}; # reset if retried
        my $pi_cfg = $ctx->{www}->{pi_cfg};
        for my $mi ($mset->items) {
                my $doc = $mi->get_document;
@@ -122,6 +122,7 @@ sub response {
        my ($re, $qs) = $ctx->url_filter;
        $re // return $ctx->psgi_triple;
        if (my $ALL = $ctx->{www}->{pi_cfg}->ALL) { # fast path
+               # FIXME: test this in t/
                $ALL->misc->reopen->retry_reopen(\&add_misc_ibx,
                                                $ctx, $re, $qs);
        } else { # slow path, no [extindex "all"] configured
@@ -189,9 +190,9 @@ sub psgi_triple {
        my $h = [ 'Content-Type', 'text/html; charset=UTF-8',
                        'Content-Length', undef ];
        my $gzf = gzf_maybe($h, $ctx->{env});
-       $gzf->zmore('<html><head><title>' .
-                               'public-inbox listing</title>' .
-                               '</head><body>');
+       $gzf->zmore('<html><head><title>public-inbox listing</title>' .
+                       $ctx->{www}->style('+/') .
+                       '</head><body>');
        my $code = 404;
        if (my $list = delete $ctx->{-list}) {
                my $mset = delete $ctx->{-mset};
@@ -212,7 +213,7 @@ sub psgi_triple {
        my $out = $gzf->zflush('</pre><hr><pre>'.
                        PublicInbox::WwwStream::code_footer($ctx->{env}) .
                        '</pre></body></html>');
-       $h->[3] = bytes::length($out);
+       $h->[3] = length($out);
        [ $code, $h, [ $out ] ];
 }