| 1 |
use strict; |
| 2 |
use warnings; |
| 3 |
use utf8; |
| 4 |
|
| 5 |
use Test::More; |
| 6 |
use Plack::Test; |
| 7 |
use HTTP::Request::Common; |
| 8 |
|
| 9 |
{ |
| 10 |
package PublicContent; |
| 11 |
use Dancer2; |
| 12 |
|
| 13 |
set public_dir => 't/corpus/static'; |
| 14 |
|
| 15 |
get '/' => sub { return 'Welcome Home' }; |
| 16 |
|
| 17 |
} |
| 18 |
|
| 19 |
my $test = Plack::Test->create( PublicContent->to_app ); |
| 20 |
|
| 21 |
subtest 'public content' => sub { |
| 22 |
my $res = $test->request( GET '/1x1.png' ); |
| 23 |
is $res->code, 200, "200 response"; |
| 24 |
my $last_modified = $res->header('Last-Modified'); |
| 25 |
|
| 26 |
$res = $test->request( GET '/1x1.png', 'If-Modified-Since' => $last_modified ); |
| 27 |
is $res->code, 304, "304 response"; |
| 28 |
}; |
| 29 |
|
| 30 |
done_testing(); |