about summary refs log tree commit diff
diff options
context:
space:
mode:
authorfranck cuny <franck@lumberjaph.net>2010-02-28 12:54:17 +0100
committerfranck cuny <franck@lumberjaph.net>2010-02-28 12:54:17 +0100
commit4730ae4d5216056d0a9c5d7dde61084feda65478 (patch)
treef381b0eae4efbf3d41cc612291df37d03c06f9ae
parentPOD (diff)
downloadplack-middleware-etag-4730ae4d5216056d0a9c5d7dde61084feda65478.tar.gz
update internal tests
-rw-r--r--lib/Plack/Middleware/ETag.pm11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/Plack/Middleware/ETag.pm b/lib/Plack/Middleware/ETag.pm
index 0b491a7..72b8c30 100644
--- a/lib/Plack/Middleware/ETag.pm
+++ b/lib/Plack/Middleware/ETag.pm
@@ -18,13 +18,10 @@ sub call {
         $res,
         sub {
             my $res = shift;
-            return unless defined $res->[2];
-            return
-                if ( Plack::Util::header_exists( $headers, 'ETag' )
-                || $env->{REQUEST_METHOD} !~ /^(GET|HEAD)$/ );
-            my $sha     = Digest::SHA->new;
-            my $content = $res->[2];
-            $sha->add(@$content);
+            return if ( !defined $res->[2] || ref $res->[2] ne 'ARRAY' );
+            return if ( Plack::Util::header_exists( $headers, 'ETag' ) );
+            my $sha = Digest::SHA->new;
+            $sha->add( @{ $res->[2] } );
             Plack::Util::header_set( $headers, 'ETag', $sha->hexdigest );
             return;
         }