The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

#!/usr/bin/env perl
# Test that the Last-Modified header is always added, but not
# overridden.
use strict;
use URI;
# setup library path
use FindBin qw($Bin);
use lib "$Bin/lib";
# make sure testapp works
use ok 'TestApp';
# a live test against TestApp, the test application
my $m = Test::WWW::Mechanize::Catalyst->new;
my $uri = URI->new('http://localhost/');
my $time = DateTime::Format::HTTP->format_datetime( DateTime->now );
my $res = $m->get($uri);
ok($res->is_success, "GET " . $res->base);
is($res->header('Last-Modified'), $time, "Last-Modified");
$time = DateTime::Format::HTTP->format_datetime(
DateTime->now->subtract( minutes => 123 )
);
$uri->query_form( 'Last-Modified' => $time, );
$res = $m->get($uri);
ok($res->is_success, "GET " . $res->base);
is($res->header('Last-Modified'), $time, "Last-Modified");
done_testing;