diff options
author | Eric Wong <e@80x24.org> | 2020-01-01 10:38:56 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2020-01-01 19:10:55 +0000 |
commit | 02f9b34f398bef722159cd54a629441f861d37b7 (patch) | |
tree | 8d58442693e693921785bd004cd1b3cb8e30266d /lib/PublicInbox/GitHTTPBackend.pm | |
parent | 6348b9adcf8a7d4a455298f45f62338e148d691a (diff) | |
download | public-inbox-02f9b34f398bef722159cd54a629441f861d37b7.tar.gz |
Remove redundant "r" functions for generating short error responses. These responses will no longer be cached by clients, which is probably a good thing since most errors ought to be transient, anyways. This also fixes error responses for our cgit wrapper when static files are missing.
Diffstat (limited to 'lib/PublicInbox/GitHTTPBackend.pm')
-rw-r--r-- | lib/PublicInbox/GitHTTPBackend.pm | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm index 8883ec34..d1132fb7 100644 --- a/lib/PublicInbox/GitHTTPBackend.pm +++ b/lib/PublicInbox/GitHTTPBackend.pm @@ -9,10 +9,9 @@ use warnings; use Fcntl qw(:seek); use IO::Handle; 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); @@ -32,18 +31,6 @@ our $ANY = join('|', @binary, @text, 'git-upload-pack'); 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) = @_; @@ -88,12 +75,12 @@ sub serve_dumb { 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 |