From e547b14775c26aab21ad24a7bd46522b5dd07522 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Sat, 7 Feb 2015 15:20:25 +0200 Subject: [PATCH] Make private sources Cache-Control: private and Vary: Authorization --- lib/Plack/App/Gruntmaster.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Plack/App/Gruntmaster.pm b/lib/Plack/App/Gruntmaster.pm index f091892..6bc1f79 100644 --- a/lib/Plack/App/Gruntmaster.pm +++ b/lib/Plack/App/Gruntmaster.pm @@ -114,8 +114,11 @@ sub dispatch_request{ sub (/src/:job) { return NOT_FOUND if !job; my $isowner = remote_user && remote_user->id eq job->rawowner; - forbid !$isowner && (job->private || job->problem->private || job->contest && job->contest->is_running); - my @headers = ('X-Forever' => 1, 'Cache-Control' => 'public, max-age=604800', 'Content-Type' => CONTENT_TYPES->{job->format}); + my $private = job->private || job->problem->private || job->contest && job->contest->is_running; + forbid !$isowner && $private; + my $privacy = $private ? 'private' : 'public'; + my @headers = ('X-Forever' => 1, 'Cache-Control' => "$privacy, max-age=604800", 'Content-Type' => CONTENT_TYPES->{job->format}); + push @headers, (Vary => 'Authorization') if $private; [200, \@headers, [job->source]] }, -- 2.39.2