diff --git a/lib/Plack/Middleware/ConditionalGET.pm b/lib/Plack/Middleware/ConditionalGET.pm index 8a9eb5ea5..9bd28f02b 100644 --- a/lib/Plack/Middleware/ConditionalGET.pm +++ b/lib/Plack/Middleware/ConditionalGET.pm @@ -12,7 +12,7 @@ sub call { $self->response_cb($res, sub { my $res = shift; - + return unless $res->[0] == 200; my $h = Plack::Util::headers($res->[1]); # check both ETag and If-Modified-Since, and at least one should exist diff --git a/t/Plack-Middleware/conditionalget.t b/t/Plack-Middleware/conditionalget.t index 483ebf14a..c0038b79e 100644 --- a/t/Plack-Middleware/conditionalget.t +++ b/t/Plack-Middleware/conditionalget.t @@ -20,6 +20,12 @@ my @tests = ( status => 304, headers => [ ETag => $tag ], }, + { + app => sub { [ 404, [ 'ETag' => $tag, 'Content-Type' => 'text/plain' ], [ 'Not Found' ] ] }, + env => { REQUEST_METHOD => "GET", HTTP_IF_NONE_MATCH => $tag }, + status => 404, + headers => [ ETag => $tag, 'Content-Type' => 'text/plain' ], + }, { app => sub { [ 200, [ 'Last-Modified' => $date, 'Content-Type' => 'text/plain' ], [ 'OK' ] ] }, env => { REQUEST_METHOD => "GET", HTTP_IF_MODIFIED_SINCE => $date }, @@ -80,8 +86,3 @@ for my $block (@tests) { is $res->[0], $block->{status}; is_deeply $res->[1], $block->{headers}; } - - - - -