[Catalyst-commits] r11330 - in
Catalyst-Plugin-Static-Simple/branches/if_modified_since:
lib/Catalyst/Plugin/Static t
hobbs at dev.catalyst.perl.org
hobbs at dev.catalyst.perl.org
Mon Sep 7 12:00:23 GMT 2009
Author: hobbs
Date: 2009-09-07 12:00:23 +0000 (Mon, 07 Sep 2009)
New Revision: 11330
Added:
Catalyst-Plugin-Static-Simple/branches/if_modified_since/t/12if_modified.t
Modified:
Catalyst-Plugin-Static-Simple/branches/if_modified_since/lib/Catalyst/Plugin/Static/Simple.pm
Log:
Sanitize headers, and add a test.
Modified: Catalyst-Plugin-Static-Simple/branches/if_modified_since/lib/Catalyst/Plugin/Static/Simple.pm
===================================================================
--- Catalyst-Plugin-Static-Simple/branches/if_modified_since/lib/Catalyst/Plugin/Static/Simple.pm 2009-09-07 11:27:47 UTC (rev 11329)
+++ Catalyst-Plugin-Static-Simple/branches/if_modified_since/lib/Catalyst/Plugin/Static/Simple.pm 2009-09-07 12:00:23 UTC (rev 11330)
@@ -179,6 +179,7 @@
$c->_debug_msg( " (not modified)" )
if $config->{debug};
+ $c->res->headers->remove_content_headers;
$c->res->status(304); # Not Modified
} else {
$c->res->headers->content_type( $type );
Added: Catalyst-Plugin-Static-Simple/branches/if_modified_since/t/12if_modified.t
===================================================================
--- Catalyst-Plugin-Static-Simple/branches/if_modified_since/t/12if_modified.t (rev 0)
+++ Catalyst-Plugin-Static-Simple/branches/if_modified_since/t/12if_modified.t 2009-09-07 12:00:23 UTC (rev 11330)
@@ -0,0 +1,23 @@
+#!perl
+
+use strict;
+use warnings;
+
+use FindBin;
+use lib "$FindBin::Bin/lib";
+
+use Test::More tests => 4;
+use Catalyst::Test 'TestApp';
+use HTTP::Request;
+
+# test getting a file via serve_static_file
+ok( my $res = request('http://localhost/images/catalyst.png'), 'got image the first time' );
+ok( my $lastmod = $res->headers->header('Last-Modified'), 'image has Last-Modified');
+
+my $req = HTTP::Request->new(GET => "http://localhost/images/catalyst.png",
+ [ "If-Modified-Since" => $lastmod ]
+);
+
+ok( $res = request($req), 'got the image with If-Modified-Since' );
+is( $res->code, 304, 'got a 304 response' );
+
More information about the Catalyst-commits
mailing list