]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwStatic.pm
nntp: inline CRLF in all response lines
[public-inbox.git] / lib / PublicInbox / WwwStatic.pm
index d0611949d29bb35bc3c819ee7459ac72bb0ab6ba..eeb5e565039ec47c7a715e1ae2c6d993cbb2dbbf 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2021 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 
 # This package can either be a PSGI response body for a static file
@@ -9,15 +9,14 @@
 # functionality of nginx.
 package PublicInbox::WwwStatic;
 use strict;
+use v5.10.1;
 use parent qw(Exporter);
-use bytes ();
 use Fcntl qw(SEEK_SET O_RDONLY O_NONBLOCK);
 use POSIX qw(strftime);
 use HTTP::Date qw(time2str);
 use HTTP::Status qw(status_message);
 use Errno qw(EACCES ENOTDIR ENOENT);
 use URI::Escape qw(uri_escape_utf8);
-use PublicInbox::NoopFilter;
 use PublicInbox::GzipFilter qw(gzf_maybe);
 use PublicInbox::Hval qw(ascii_html);
 use Plack::MIME;
@@ -219,7 +218,7 @@ my %path_re_cache;
 sub path_info_raw ($) {
        my ($env) = @_;
        my $sn = $env->{SCRIPT_NAME};
-       my $re = $path_re_cache{$sn} ||= do {
+       my $re = $path_re_cache{$sn} //= do {
                $sn = '/'.$sn unless index($sn, '/') == 0;
                $sn =~ s!/\z!!;
                qr!\A(?:https?://[^/]+)?\Q$sn\E(/[^\?\#]+)!;
@@ -313,13 +312,13 @@ sub dir_response ($$$) {
 
        my $path_info_html = ascii_html($path_info);
        my $h = [qw(Content-Type text/html Content-Length), undef];
-       my $gzf = gzf_maybe($h, $env) || PublicInbox::NoopFilter::new();
+       my $gzf = gzf_maybe($h, $env);
        $gzf->zmore("<html><head><title>Index of $path_info_html</title>" .
                ${$self->{style}} .
                "</head><body><pre>Index of $path_info_html</pre><hr><pre>\n");
        $gzf->zmore(join("\n", @entries));
        my $out = $gzf->zflush("</pre><hr></body></html>\n");
-       $h->[3] = bytes::length($out);
+       $h->[3] = length($out);
        [ 200, $h, [ $out ] ]
 }