diff options
author | Franck Cuny <franckcuny@gmail.com> | 2015-07-07 11:28:18 -0700 |
---|---|---|
committer | Franck Cuny <franckcuny@gmail.com> | 2015-07-07 11:39:58 -0700 |
commit | 327df973ccdd0def50a4448a3161df8dc76b8a03 (patch) | |
tree | 23aeb36e8f20a4295ddb4442c25716685ce72e58 | |
parent | Drop Perl 5.10 from Travis (diff) | |
download | plack-middleware-etag-327df973ccdd0def50a4448a3161df8dc76b8a03.tar.gz |
Fix off-by-one error.
When calling the `stat` function on a file, the inode number is stored in the second element (index 1) of the array, not the third (index 2). Instead of getting the inode we were using the mode, which is incorrect.
-rw-r--r-- | lib/Plack/Middleware/ETag.pm | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/lib/Plack/Middleware/ETag.pm b/lib/Plack/Middleware/ETag.pm index 22dcc01..86912f4 100644 --- a/lib/Plack/Middleware/ETag.pm +++ b/lib/Plack/Middleware/ETag.pm @@ -35,13 +35,12 @@ sub call { my $file_attr = $self->file_etag || [qw/inode mtime size/]; my @stats = stat $res->[2]; if ( $stats[9] == time - 1 ) { - - # if the file was modified less than one second before the request - # it may be modified in a near future, so we return a weak etag + # if the file was modified less than one second before the request + # it may be modified in a near future, so we return a weak etag $etag = "W/"; } if ( grep {/inode/} @$file_attr ) { - $etag .= ( sprintf "%x", $stats[2] ); + $etag .= ( sprintf "%x", $stats[1] ); } if ( grep {/mtime/} @$file_attr ) { $etag .= "-" if ( $etag && $etag !~ /-$/ ); |