[Jifty-commit] r1785 - in jifty/trunk: . lib/Jifty/View/Mason
share/web/templates/__jifty/css share/web/templates/__jifty/js
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Wed Aug 9 15:06:01 EDT 2006
Author: clkao
Date: Wed Aug 9 15:05:50 2006
New Revision: 1785
Added:
jifty/trunk/t/TestApp/t/10-compress.t (contents, props changed)
Modified:
jifty/trunk/MANIFEST
jifty/trunk/Makefile.PL
jifty/trunk/lib/Jifty/View/Mason/Handler.pm
jifty/trunk/share/web/templates/__jifty/css/dhandler
jifty/trunk/share/web/templates/__jifty/js/dhandler
Log:
* Don't do compression in the css/js dhandlers.
* Test for compressed response.
Modified: jifty/trunk/MANIFEST
==============================================================================
--- jifty/trunk/MANIFEST (original)
+++ jifty/trunk/MANIFEST Wed Aug 9 15:05:50 2006
@@ -368,5 +368,7 @@
t/TestApp/t/06-validation.t
t/TestApp/t/07-sandboxing.t
t/TestApp/t/08-notifications.t
+t/TestApp/t/09-redirect.t
+t/TestApp/t/10-compress.t
t/TestApp/t/config-Cachable
t/TestApp/t/config-Record
Modified: jifty/trunk/Makefile.PL
==============================================================================
--- jifty/trunk/Makefile.PL (original)
+++ jifty/trunk/Makefile.PL Wed Aug 9 15:05:50 2006
@@ -52,6 +52,7 @@
requires('Object::Declare' => '0.13');
requires('PAR::Dist::FromCPAN');
requires('Params::Validate');
+requires('PerlIO::gzip');
requires('Pod::Simple'); #Pod::Simple::Text
requires('Scalar::Defer' => '0.06');
requires('String::Koremutake');
Modified: jifty/trunk/lib/Jifty/View/Mason/Handler.pm
==============================================================================
--- jifty/trunk/lib/Jifty/View/Mason/Handler.pm (original)
+++ jifty/trunk/lib/Jifty/View/Mason/Handler.pm Wed Aug 9 15:05:50 2006
@@ -80,7 +80,8 @@
unless ($r->http_header_sent or not $m->auto_send_headers) {
my $want_gzip = 0;
- if (Jifty->handler->cgi->http('Accept-Encoding') =~ /\bgzip\b/) {
+
+ if (Jifty::View::Static::Handler->client_accepts_gzipped_content) {
++$want_gzip;
$r->header_out( "Content-Encoding" => "gzip" );
}
Modified: jifty/trunk/share/web/templates/__jifty/css/dhandler
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/css/dhandler (original)
+++ jifty/trunk/share/web/templates/__jifty/css/dhandler Wed Aug 9 15:05:50 2006
@@ -20,20 +20,8 @@
$r->content_type("text/css");
$r->header_out( 'Expires' => HTTP::Date::time2str(time + 31536000) );
-# XXX TODO: If we start caching the squished CSS in a file somewhere, we
-# can have the static handler serve it, which would take care of gzipping
-# for us.
-use Compress::Zlib qw();
+Jifty->log->debug("Sending squished CSS");
+print Jifty->web->cached_css;
-if ( Jifty::View::Static::Handler->client_accepts_gzipped_content ) {
- Jifty->log->debug("Sending gzipped squished CSS");
- $r->header_out( "Content-Encoding" => "gzip" );
- binmode STDOUT;
- print Compress::Zlib::memGzip( Jifty->web->cached_css );
-}
-else {
- Jifty->log->debug("Sending squished CSS");
- print Jifty->web->cached_css;
-}
return;
</%init>
Modified: jifty/trunk/share/web/templates/__jifty/js/dhandler
==============================================================================
--- jifty/trunk/share/web/templates/__jifty/js/dhandler (original)
+++ jifty/trunk/share/web/templates/__jifty/js/dhandler Wed Aug 9 15:05:50 2006
@@ -20,20 +20,8 @@
$r->content_type("application/x-javascript");
$r->header_out( 'Expires' => HTTP::Date::time2str(time + 31536000) );
-# XXX TODO: If we start caching the squished JS in a file somewhere, we
-# can have the static handler serve it, which would take care of gzipping
-# for us.
-use Compress::Zlib qw();
+Jifty->log->debug("Sending squished JS");
+print Jifty->web->cached_javascript;
-if ( Jifty::View::Static::Handler->client_accepts_gzipped_content ) {
- Jifty->log->debug("Sending gzipped squished JS");
- $r->header_out( "Content-Encoding" => "gzip" );
- binmode STDOUT;
- print Compress::Zlib::memGzip( Jifty->web->cached_javascript );
-}
-else {
- Jifty->log->debug("Sending squished JS");
- print Jifty->web->cached_javascript;
-}
return;
</%init>
Added: jifty/trunk/t/TestApp/t/10-compress.t
==============================================================================
--- (empty file)
+++ jifty/trunk/t/TestApp/t/10-compress.t Wed Aug 9 15:05:50 2006
@@ -0,0 +1,31 @@
+use warnings;
+use strict;
+use Compress::Zlib;
+
+=head1 DESCRIPTION
+
+If we do a redirect in a 'before' in the dispatcher, actions should
+still get run.
+
+=cut
+
+use lib 't/lib';
+use Jifty::SubTest;
+BEGIN { $ENV{'JIFTY_CONFIG'} = 't/config-Cachable' }
+
+use Jifty::Test tests => 5;
+use Jifty::Test::WWW::Mechanize;
+
+my $server = Jifty::Test->make_server;
+my $URL = $server->started_ok;
+
+my $mech = Jifty::Test::WWW::Mechanize->new();
+$mech->get_ok($URL);
+my $expected = $mech->response->content;
+like($expected, qr/Jifty Test Application/);
+
+my $request = HTTP::Request->new( GET => "$URL/", ['Accept-Encoding' => 'gzip'] );
+my $response = $mech->request( $request );
+is($response->header('Content-Encoding'), 'gzip');
+# blah, can't check if this is same as expected because there are continuation serials.
+like(Compress::Zlib::memGunzip($response->content), qr/Jifty Test Application/);
More information about the Jifty-commit
mailing list