]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/WwwStatic.pm
wwwstatic: set "Vary: Accept-Encoding" in static gzip response
[public-inbox.git] / lib / PublicInbox / WwwStatic.pm
index 60a71d8d20f007eaa150e7f22866df782c8c7761..3c933156405bedb92db5afee4a3beed6a29506bc 100644 (file)
@@ -1,4 +1,4 @@
-# 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>
 
 # This package can either be a PSGI response body for a static file
@@ -117,7 +117,9 @@ sub try_gzip_static ($$$$) {
        return unless -f $gz && (stat(_))[9] == $mtime;
        my $res = response($env, $h, $gz, $type);
        return if ($res->[0] > 300 || $res->[0] < 200);
-       push @{$res->[1]}, qw(Cache-Control no-transform Content-Encoding gzip);
+       push @{$res->[1]}, qw(Cache-Control no-transform
+                               Content-Encoding gzip
+                               Vary Accept-Encoding);
        $res;
 }
 
@@ -176,9 +178,9 @@ sub getline {
        my $len = $self->{len} or return; # undef, tells server we're done
        my $n = 8192;
        $n = $len if $len < $n;
-       seek($self->{in}, $self->{off}, SEEK_SET) or
-                       die "seek ($self->{path}): $!";
-       my $r = read($self->{in}, my $buf, $n);
+       sysseek($self->{in}, $self->{off}, SEEK_SET) or
+                       die "sysseek ($self->{path}): $!";
+       my $r = sysread($self->{in}, my $buf, $n);
        if (defined $r && $r > 0) { # success!
                $self->{len} = $len - $r;
                $self->{off} += $r;