-# Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# when no endpoints match, fallback to this and serve a static file
use strict;
use warnings;
use Fcntl qw(:seek);
-use IO::Handle;
+use IO::Handle; # ->flush
use HTTP::Date qw(time2str);
-use HTTP::Status qw(status_message);
use PublicInbox::Qspawn;
use PublicInbox::Tmpfile;
-use PublicInbox::WwwStatic;
+use PublicInbox::WwwStatic qw(r @NO_CACHE);
# 32 is same as the git-daemon connection limit
my $default_limiter = PublicInbox::Qspawn::Limiter->new(32);
my $BIN = join('|', @binary);
my $TEXT = join('|', @text);
-my @no_cache = ('Expires', 'Fri, 01 Jan 1980 00:00:00 GMT',
- 'Pragma', 'no-cache',
- 'Cache-Control', 'no-cache, max-age=0, must-revalidate');
-
-sub r ($;$) {
- my ($code, $msg) = @_;
- $msg ||= status_message($code);
- my $len = length($msg);
- [ $code, [qw(Content-Type text/plain Content-Length), $len, @no_cache],
- [$msg] ]
-}
-
sub serve {
my ($env, $git, $path) = @_;
cache_one_year($h);
} elsif ($path =~ /\A(?:$TEXT)\z/o) {
$type = 'text/plain';
- push @$h, @no_cache;
+ push @$h, @NO_CACHE;
} else {
return r(404);
}
$path = "$git->{git_dir}/$path";
- PublicInbox::WwwStatic::response($env, $h, $path, $type) // r(404);
+ PublicInbox::WwwStatic::response($env, $h, $path, $type);
}
sub git_parse_hdr { # {parse_hdr} for Qspawn