]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwStatic.pm
wwwstatic: offload error handling to PSGI server
[public-inbox.git] / lib / PublicInbox / WwwStatic.pm
index bc42236e57b6e6442db9c7351e76587f68d3d871..e1f536f3f21c1d7ce63ea74f140d2646fb1284b1 100644 (file)
@@ -12,7 +12,7 @@ use strict;
 use parent qw(Exporter);
 use bytes ();
 use Fcntl qw(SEEK_SET O_RDONLY O_NONBLOCK);
-use POSIX qw(strftime lround);
+use POSIX qw(strftime);
 use HTTP::Date qw(time2str);
 use HTTP::Status qw(status_message);
 use Errno qw(EACCES ENOTDIR ENOENT);
@@ -169,16 +169,7 @@ sub getline {
                return $buf;
        }
        my $m = defined $r ? "EOF with $len bytes left" : "read error: $!";
-       my $env = $self->{env};
-       $env->{'psgi.errors'}->print("$self->{path} $m\n");
-
-       # drop the client on error
-       if (my $io = $env->{'psgix.io'}) {
-               $io->close; # this is likely PublicInbox::DS::close
-       } else { # for some PSGI servers w/o psgix.io
-               die "dropping client socket\n";
-       }
-       undef;
+       die "$self->{path} $m, dropping client socket\n";
 }
 
 sub close {} # noop, called by PSGI server, just let everything go out-of-scope
@@ -238,7 +229,7 @@ sub human_size ($) {
                        last;
                }
        }
-       lround($size).$suffix;
+       sprintf('%lu', $size).$suffix;
 }
 
 # by default, this returns "index.html" if it exists for a given directory