diff options
Diffstat (limited to 't')
| -rw-r--r-- | t/01_basic.t | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/t/01_basic.t b/t/01_basic.t index 0bc49c6..8564ece 100644 --- a/t/01_basic.t +++ b/t/01_basic.t @@ -9,6 +9,7 @@ use Plack::Builder; use HTTP::Request::Common; my $content = [qw/hello world/]; +my $sha = Digest::SHA->new->add(@$content)->hexdigest; my $handler = builder { enable "Plack::Middleware::ETag"; @@ -25,6 +26,12 @@ my $second_handler = builder { }; }; +my $unmodified_handler = builder { + enable "Plack::Middleware::ConditionalGET"; + enable "Plack::Middleware::ETag"; + sub { [ '200', [ 'Content-Type' => 'text/html' ], $content ] }; +}; + test_psgi app => $handler, client => sub { @@ -33,8 +40,7 @@ test_psgi my $req = GET "http://localhost/"; my $res = $cb->($req); ok $res->header('ETag'); - my $sha = Digest::SHA->new->add(@$content); - is $res->header('ETag'), $sha->hexdigest; + is $res->header('ETag'), $sha; } }; @@ -50,4 +56,17 @@ test_psgi } }; +test_psgi + app => $unmodified_handler, + client => sub { + my $cb = shift; + { + my $req = GET "http://localhost/", 'If-None-Match' => $sha; + my $res = $cb->($req); + ok $res->header('ETag'); + is $res->code, 304; + ok !$res->content; + } +}; + done_testing; |
