[Jifty-commit] jifty branch, plack-rebased, updated. ace3cff19386702af03591d50d62947de0277bfd

Jifty commits jifty-commit at lists.jifty.org
Fri Feb 5 03:48:07 EST 2010


The branch, plack-rebased has been updated
       via  ace3cff19386702af03591d50d62947de0277bfd (commit)
       via  6074ce55765df2a03c37e617d35d1785a1991516 (commit)
       via  fca36db27599ece47b48dcbe7db8189b5c9eaf6b (commit)
       via  1d90579c4448ceba113fae1bbdfd515c021b5ae0 (commit)
       via  9de9bbce7ccbd3319c7fb5278c062787df2db608 (commit)
       via  5dca482fad462a00016e7be9fa3d39bc35c2cba9 (commit)
       via  1de339706900761c74190a8f31f1fc3fa46fe47f (commit)
       via  bbd5a22caa118517ceb557976b0cb57d6fb22cb7 (commit)
       via  dbbfa1adc33a1ed9cdc02134a29e6010855989d3 (commit)
       via  0ae1e3075afcb98e7bfbeb37b0fae1de6047e52a (commit)
       via  e11809d2b21ebdd67f6d068a4c5935246a5bcee9 (commit)
       via  be0a4a683aadea16014343a8499dd923334b76f8 (commit)
       via  c41ff6dab5371b716c401ca14b40532fa13b6588 (commit)
       via  b0a8006ed25a0c4f6662fc411174acc4a991ab76 (commit)
       via  cb063d64f3cc3d2941e970d0798c9d12c521cd5a (commit)
       via  15f32fdfd89b01e2395885a1e5f59364d25ea5ea (commit)
       via  f8785c88100d12be38eebed4e4791a62e354591b (commit)
       via  7c76e2bdde55cae69693933e243eced1b81e9b57 (commit)
       via  7d67747a1aef89854e50acf734d40a5b6c41eb3a (commit)
       via  9196d3d0661490d6064ec8044f1e06ad8a72b950 (commit)
       via  5396e2e35b96b0aebc9f3086b0b90e12f57aeea8 (commit)
       via  44359d5a34b95bcd2acf238f6d3eff815c235f03 (commit)
       via  409707d0b5faa01b126cb26aad4edea883a7c975 (commit)
       via  57a4fcc33ad624d6004913cf80e0ee69775e5755 (commit)
       via  75d11b59bfb3cbb381ec76d6b6de606aac9a3933 (commit)
       via  d572a6d5e94bf7f2389ef035d460a174e8395978 (commit)
       via  8dfd20ed1bb64a0b383f821082f6c4864270c98f (commit)
      from  1b39275c9ecf12c8927175bd4ef0b6dc60a0aafe (commit)

Summary of changes:
 Makefile.PL                                        |   10 +-
 lib/Jifty.pm                                       |    6 +
 lib/Jifty/CAS.pm                                   |   97 +++++++----
 lib/Jifty/CAS/Blob.pm                              |   13 +--
 lib/Jifty/{CAS.pm => CAS/Store.pm}                 |   47 +++---
 lib/Jifty/CAS/Store/Memcached.pm                   |  178 ++++++++++++++++++++
 lib/Jifty/Config.pm                                |   10 +
 lib/Jifty/Dispatcher.pm                            |    4 +-
 lib/Jifty/Handler.pm                               |   22 +++-
 lib/Jifty/Plugin/CompressedCSSandJS.pm             |   46 +-----
 lib/Jifty/Plugin/CompressedCSSandJS/Dispatcher.pm  |    7 +-
 lib/Jifty/Plugin/Halo.pm                           |    5 +-
 lib/Jifty/Request.pm                               |   51 ++++--
 lib/Jifty/Test.pm                                  |    5 +
 lib/Jifty/Test/WWW/Mechanize.pm                    |   18 ++-
 lib/Jifty/View/Static/Handler.pm                   |   55 +-----
 lib/Jifty/Web/FileUpload.pm                        |    5 +-
 lib/Jifty/Web/Form/Field.pm                        |   10 +-
 lib/Jifty/Web/Form/Field/Button.pm                 |    2 +-
 lib/Jifty/Web/Session.pm                           |   30 ++--
 share/web/templates/__jifty/halo                   |    3 +-
 t/Jifty.pm                                         |    2 +-
 t/TestApp-Collection-Select/etc/config.yml         |    2 +-
 t/TestApp-Dispatcher/etc/config.yml                |    2 +-
 t/TestApp-JiftyJS/etc/config.yml                   |    2 +-
 t/TestApp-JiftyJS/lib/TestApp/JiftyJS/View.pm      |    4 +-
 .../share/web/static/js-test/01.behaviour.html     |    2 +-
 .../share/web/static/js-test/02.action.html        |    2 +-
 t/TestApp-JiftyJS/t/2-behaviour.t                  |    5 +-
 t/TestApp-JiftyJS/t/5-action.t                     |    2 +-
 t/TestApp-JiftyJS/t/6-offer-actions.t              |    8 +-
 t/TestApp-Mason/etc/config.yml                     |    2 +-
 t/TestApp-Notifications/etc/config.yml             |    2 +-
 t/TestApp-Plugin-ActorMetadata/etc/config.yml      |    2 +-
 t/TestApp-Plugin-AppPluginHasModels/etc/config.yml |    2 +-
 t/TestApp-Plugin-CompressedCSSandJS/etc/config.yml |    2 +-
 t/TestApp-Plugin-OnClick/etc/config.yml            |    2 +-
 t/TestApp-Plugin-SinglePage/etc/config.yml         |    2 +-
 t/TestApp-Regions/etc/config.yml                   |    2 +-
 t/TestApp-RestartServer/etc/config.yml             |    2 +-
 t/TestApp-Template-Declare/etc/config.yml          |    2 +-
 t/TestApp-Uploads/etc/config.yml                   |    2 +-
 t/TestApp/t/06-validation.t                        |    4 +-
 t/TestApp/t/10-compress.t                          |   23 ++-
 t/cas-memcached.t                                  |   60 +++++++
 t/cas-memcached.t-config.yml                       |    7 +
 46 files changed, 517 insertions(+), 254 deletions(-)
 copy lib/Jifty/{CAS.pm => CAS/Store.pm} (53%)
 create mode 100644 lib/Jifty/CAS/Store/Memcached.pm
 create mode 100644 t/cas-memcached.t
 create mode 100644 t/cas-memcached.t-config.yml

- Log -----------------------------------------------------------------
commit 1de339706900761c74190a8f31f1fc3fa46fe47f
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Fri Jan 29 21:47:06 2010 +0800

    Merge branch 'plack-1.0' into plack

diff --git a/Makefile.PL b/Makefile.PL
index 72ee040..138379e 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -13,7 +13,6 @@ requires('Class::Data::Inheritable');
 requires('Class::Trigger' => '0.13');
 requires('Clone' => '0.27');
 requires('CGI' => '3.30');
-requires('CGI::Simple'); # CGI::Simple::Cookie
 requires('CGI::Cookie::Splitter');
 requires('Class::Inspector' => 1.20); # For File::ShareDir on Win32
 requires('Crypt::CBC');
@@ -51,6 +50,7 @@ requires('HTTP::Date');
 requires('HTTP::Server::Simple' => '0.35');  # HTTP::Server::Simple::CGI
 requires('HTTP::Server::Simple::Recorder');
 requires('Hash::Merge');
+requires('Hash::MultiValue', 0.05);
 requires('Hook::LexWrap');
 requires('IPC::PubSub' => '0.23' );
 requires('IPC::Run3');
@@ -69,7 +69,7 @@ requires('Module::Refresh');
 requires('Module::ScanDeps');
 requires('Object::Declare' => '0.13');
 requires('Params::Validate');
-requires('Plack' => '0.9032'); # Plack::Loader Plack::Test Plack::Util
+requires('Plack' => '0.99_01'); # Plack::Loader Plack::Test Plack::Util
 requires('Plack::Request');
 requires('Scalar::Defer' => '0.12');
 requires('Shell::Command');
diff --git a/lib/Jifty/Handler.pm b/lib/Jifty/Handler.pm
index 03c6566..2a04d24 100644
--- a/lib/Jifty/Handler.pm
+++ b/lib/Jifty/Handler.pm
@@ -27,6 +27,7 @@ use base qw/Class::Accessor::Fast Jifty::Object/;
 use Jifty::View::Declare::Handler ();
 use Class::Trigger;
 use String::BufferStack;
+use Plack::Request;
 
 __PACKAGE__->mk_accessors(qw(dispatcher _view_handlers stash buffer));
 
diff --git a/lib/Jifty/Request.pm b/lib/Jifty/Request.pm
index dd6d7fa..9a79b47 100644
--- a/lib/Jifty/Request.pm
+++ b/lib/Jifty/Request.pm
@@ -4,7 +4,7 @@ use strict;
 package Jifty::Request;
 
 use Any::Moose;
-extends 'Plack::Request', 'Jifty::Object';
+extends 'Jifty::Object';
 
 has 'env' => (is => "ro", isa => "HashRef", default => sub { {} });
 has '_top_request' => (is => 'rw');
@@ -16,12 +16,29 @@ has 'future_continuation_id' => (is => 'rw');
 has 'continuation_type' => (is => 'rw');
 has 'continuation_path' => (is => 'rw');
 
-around 'method' => sub {
-    my ($orig, $self, $arg) = @_;
-    $self->{env}{REQUEST_METHOD} = $arg
-        if $arg;
-    $orig->($self, $arg ? $arg : ());
-};
+has 'parameters' => (is => 'rw', isa => 'HashRef');
+has 'uploads' => (is => 'rw', isa => 'HashRef');
+has 'headers' => (is => 'rw', isa => 'HTTP::Headers', default => sub { HTTP::Headers->new });
+has 'uri' => (is => 'rw', isa => 'URI', default => sub { URI->new('http:///') });
+
+sub address     { $_[0]->env->{REMOTE_ADDR} }
+sub remote_host { $_[0]->env->{REMOTE_HOST} }
+sub protocol    { $_[0]->env->{SERVER_PROTOCOL} }
+sub method      { $_[0]->env->{REQUEST_METHOD} = $_[1] if @_ > 1; $_[0]->env->{REQUEST_METHOD} }
+sub port        { $_[0]->env->{SERVER_PORT} }
+sub user        { $_[0]->env->{REMOTE_USER} }
+sub request_uri { $_[0]->env->{REQUEST_URI} }
+sub path_info   { $_[0]->env->{PATH_INFO} }
+sub script_name { $_[0]->env->{SCRIPT_NAME} }
+sub scheme      { $_[0]->env->{'psgi.url_scheme'} }
+sub secure      { $_[0]->scheme eq 'https' }
+sub body        { $_[0]->env->{'psgi.input'} }
+sub input       { $_[0]->env->{'psgi.input'} }
+
+sub header { shift->headers->header(@_) }
+sub path { shift->uri->path(@_) }
+sub content_length   { shift->headers->content_length(@_) }
+sub content_type     { shift->headers->content_type(@_) }
 
 use Jifty::JSON;
 use Jifty::YAML;
@@ -144,16 +161,23 @@ sub promote {
     die Carp::longmess("old calling style") unless ref $req;
 
     # Import all props from Plack::Request object
-    my $self = bless $req, $class;
+    my $self = bless {}, $class;
     $self->{'actions'} = {};
     $self->{'state_variables'} = {};
     $self->{'fragments'} = {};
     $self->arguments({});
     $self->template_arguments({});
 
+    $req->cookies; # vivify plack.cookie.parsed
+    $self->{env} = $req->env;
+    $self->uri($req->uri);
+    $self->headers($req->headers);
+    $self->parameters($req->parameters->mixed);
+    $self->uploads($req->uploads->mixed);
+
     # Grab content type and posted data, if any
     my $ct   = $req->content_type;
-    my $data = $req->raw_body;
+    my $data = $req->content;
 
     # Check it for something appropriate
     if ($data) {
diff --git a/lib/Jifty/Web/Session.pm b/lib/Jifty/Web/Session.pm
index 64ab825..23171f5 100644
--- a/lib/Jifty/Web/Session.pm
+++ b/lib/Jifty/Web/Session.pm
@@ -3,7 +3,6 @@ use strict;
 
 package Jifty::Web::Session;
 use base qw/Jifty::Object/;
-use CGI::Simple::Cookie ();
 use DateTime    ();
 use Storable    ();
 $Storable::Deparse    = 1;
@@ -111,11 +110,9 @@ sub load_by_kv {
 
 sub _get_session_id_from_client {
     my $self        = shift;
-    my %cookies     = Jifty->web->request ? CGI::Simple::Cookie->parse(Jifty->web->request->env->{HTTP_COOKIE}) : ();
-    my $cookie_name = $self->cookie_name;
-    my $session_id
-        = $cookies{$cookie_name} ? $cookies{$cookie_name}->value() : undef;
-    return $session_id;
+    my $cookies     = Jifty->web->request
+        ? Jifty->web->request->env->{'plack.cookie.parsed'} : {};
+    return $cookies->{$self->cookie_name};
 }
 
 =head2 unload
@@ -321,19 +318,14 @@ sub set_cookie {
     $self->load unless $self->loaded;
 
     my $cookie_name = $self->cookie_name;
-    my %cookies     = Jifty->web->request ? CGI::Simple::Cookie->parse(Jifty->web->request->env->{HTTP_COOKIE}) : ();
-
-    my $cookie      = CGI::Simple::Cookie->new(
-        -name    => $cookie_name,
-        -value   => $self->id,
-        -expires => $self->expires,
-    );
-
-    if ( not $cookies{$cookie_name}
-        or ( $cookies{$cookie_name} ne $cookie->as_string ) )
-    {
-        Jifty->web->response->cookies->{$cookie->name} = $cookie;
-    }
+    my $cookies     = Jifty->web->request ? Jifty->web->request->env->{'plack.cookie.parsed'} : {};
+    my $cookie      = {
+        value   => $self->id,
+        expires => $self->expires,
+    };
+    # XXX: do we every need to check the existing cookie to decide if
+    # we want to set the cookie this time?
+    Jifty->web->response->cookies->{$cookie_name} = $cookie;
 }
 
 =head2 cookie_name
diff --git a/t/Jifty.pm b/t/Jifty.pm
index 37edbb5..428a7e9 100644
--- a/t/Jifty.pm
+++ b/t/Jifty.pm
@@ -17,6 +17,7 @@ sub request_from_webform {
     my $form = shift;
     my $r = Jifty::Request->new->from_webform(%$form);
     delete $r->{env};
+    delete $r->{headers};
     return $r;
 }
 

commit 5dca482fad462a00016e7be9fa3d39bc35c2cba9
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Fri Jan 29 23:34:52 2010 +0800

    Plack::Request::Upload no longer provides fh.

diff --git a/lib/Jifty/Web/FileUpload.pm b/lib/Jifty/Web/FileUpload.pm
index 5f24fba..032f4d4 100644
--- a/lib/Jifty/Web/FileUpload.pm
+++ b/lib/Jifty/Web/FileUpload.pm
@@ -134,7 +134,10 @@ sub new_from_plack {
     my $self = shift;
     my $u    = shift;
 
-    $self->new(filehandle   => $u->fh,
+    open my $fh, '<:raw', $u->tempname
+        or die "Can't open '@{[ $u->tempname ]}': '$!'";
+
+    $self->new(filehandle   => $fh,
                filename     => $u->filename,
                content_type => $u->type,
            );

commit 9de9bbce7ccbd3319c7fb5278c062787df2db608
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Fri Jan 29 23:35:22 2010 +0800

    Default request parameters to empty hashref.

diff --git a/lib/Jifty/Request.pm b/lib/Jifty/Request.pm
index 9a79b47..4346341 100644
--- a/lib/Jifty/Request.pm
+++ b/lib/Jifty/Request.pm
@@ -16,7 +16,7 @@ has 'future_continuation_id' => (is => 'rw');
 has 'continuation_type' => (is => 'rw');
 has 'continuation_path' => (is => 'rw');
 
-has 'parameters' => (is => 'rw', isa => 'HashRef');
+has 'parameters' => (is => 'rw', isa => 'HashRef', default => sub { {} });
 has 'uploads' => (is => 'rw', isa => 'HashRef');
 has 'headers' => (is => 'rw', isa => 'HTTP::Headers', default => sub { HTTP::Headers->new });
 has 'uri' => (is => 'rw', isa => 'URI', default => sub { URI->new('http:///') });
diff --git a/t/Jifty.pm b/t/Jifty.pm
index 428a7e9..78c9828 100644
--- a/t/Jifty.pm
+++ b/t/Jifty.pm
@@ -16,8 +16,7 @@ use Test::Base::Filter -Base;
 sub request_from_webform {
     my $form = shift;
     my $r = Jifty::Request->new->from_webform(%$form);
-    delete $r->{env};
-    delete $r->{headers};
+    delete $r->{$_} for qw(env headers parameters);
     return $r;
 }
 

commit 1d90579c4448ceba113fae1bbdfd515c021b5ae0
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Sat Jan 30 12:40:06 2010 +0800

    Use proper constructor in Jifty::Request->promote and avoid accessing cookies from env.

diff --git a/lib/Jifty/Request.pm b/lib/Jifty/Request.pm
index 4346341..25e51a9 100644
--- a/lib/Jifty/Request.pm
+++ b/lib/Jifty/Request.pm
@@ -20,6 +20,7 @@ has 'parameters' => (is => 'rw', isa => 'HashRef', default => sub { {} });
 has 'uploads' => (is => 'rw', isa => 'HashRef');
 has 'headers' => (is => 'rw', isa => 'HTTP::Headers', default => sub { HTTP::Headers->new });
 has 'uri' => (is => 'rw', isa => 'URI', default => sub { URI->new('http:///') });
+has 'cookies' => (is => 'rw', isa => 'HashRef', default => sub { {} } );
 
 sub address     { $_[0]->env->{REMOTE_ADDR} }
 sub remote_host { $_[0]->env->{REMOTE_HOST} }
@@ -161,19 +162,17 @@ sub promote {
     die Carp::longmess("old calling style") unless ref $req;
 
     # Import all props from Plack::Request object
-    my $self = bless {}, $class;
-    $self->{'actions'} = {};
-    $self->{'state_variables'} = {};
-    $self->{'fragments'} = {};
-    $self->arguments({});
-    $self->template_arguments({});
-
-    $req->cookies; # vivify plack.cookie.parsed
-    $self->{env} = $req->env;
-    $self->uri($req->uri);
-    $self->headers($req->headers);
-    $self->parameters($req->parameters->mixed);
-    $self->uploads($req->uploads->mixed);
+    my $self = $class->new( env => $req->env,
+                            headers => $req->headers,
+                            parameters => $req->parameters->mixed,
+                            uploads => $req->uploads->mixed,
+                            uri => $req->uri,
+                            cookies => $req->cookies,
+                            actions => {},
+                            state_variables => {},
+                            fragments => {},
+                            arguments => {},
+                            template_arguments => {} );
 
     # Grab content type and posted data, if any
     my $ct   = $req->content_type;
diff --git a/lib/Jifty/Web/Session.pm b/lib/Jifty/Web/Session.pm
index 23171f5..fb0106b 100644
--- a/lib/Jifty/Web/Session.pm
+++ b/lib/Jifty/Web/Session.pm
@@ -111,7 +111,7 @@ sub load_by_kv {
 sub _get_session_id_from_client {
     my $self        = shift;
     my $cookies     = Jifty->web->request
-        ? Jifty->web->request->env->{'plack.cookie.parsed'} : {};
+        ? Jifty->web->request->cookies : {};
     return $cookies->{$self->cookie_name};
 }
 
@@ -318,7 +318,7 @@ sub set_cookie {
     $self->load unless $self->loaded;
 
     my $cookie_name = $self->cookie_name;
-    my $cookies     = Jifty->web->request ? Jifty->web->request->env->{'plack.cookie.parsed'} : {};
+    my $cookies     = Jifty->web->request ? Jifty->web->request->cookies : {};
     my $cookie      = {
         value   => $self->id,
         expires => $self->expires,
diff --git a/t/Jifty.pm b/t/Jifty.pm
index 78c9828..16542d9 100644
--- a/t/Jifty.pm
+++ b/t/Jifty.pm
@@ -16,7 +16,7 @@ use Test::Base::Filter -Base;
 sub request_from_webform {
     my $form = shift;
     my $r = Jifty::Request->new->from_webform(%$form);
-    delete $r->{$_} for qw(env headers parameters);
+    delete $r->{$_} for qw(env headers parameters cookies);
     return $r;
 }
 

commit fca36db27599ece47b48dcbe7db8189b5c9eaf6b
Merge: 1d90579 bbd5a22
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Fri Feb 5 14:34:44 2010 +0800

    Merge branch 'master' into plack-rebased
    
    Conflicts:
    	lib/Jifty/Plugin/CompressedCSSandJS.pm
    	lib/Jifty/Test.pm

diff --cc lib/Jifty/CAS.pm
index 1e4829e,b6aecde..1fc03ba
--- a/lib/Jifty/CAS.pm
+++ b/lib/Jifty/CAS.pm
@@@ -78,11 -57,67 +57,66 @@@ C<NAME>, or undef if none such exists
  Returns a L<Jifty::CAS::Blob> for the given pair of C<DOMAIN> and
  C<KEY>, or undef if none such exists.
  
+ =head2 serve_by_name DOMAIN NAME REQUESTED_KEY
+ 
+ Intelligently serves up the content of the object at NAME (B<not>
+ REQUESTED_KEY) in DOMAIN.  REQUESTED_KEY is currently used only to check if the
+ content at NAME equals the content requested.  If so, this method responds with
+ an HTTP 304 status, indicating the content hasn't changed.  This use case
+ assumes that content is served to clients from the CAS with the CAS key (an MD5
+ sum) as the filename or part of it.
+ 
+ The C<content_type> key in the requested object's metadata is expected to be
+ set and is used for the HTTP response.  If a true value is set for C<deflate>
+ in the object's metadata, then this method will serve gzipped content if the
+ client supports it.
+ 
+ This method is usually called from a dispatcher rule.  Returns the HTTP status
+ code set by this method (possibly for your use in the dispatcher).
+ 
  =cut
  
- sub retrieve {
-     my ($class, $domain, $key) = @_;
-     return $CONTAINER{$domain}{DB}{$key};
+ sub serve_by_name {
+     my ($class, $domain, $name, $incoming_key) = @_;
+     my $key = Jifty::CAS->key($domain, $name);
+ 
+     return $class->_serve_404( $domain, $name, "Unable to lookup key." )
+         if not defined $key;
+ 
 -    if ( Jifty->handler->cgi->http('If-Modified-Since') and $incoming_key eq $key ) {
++    if ( Jifty->web->request->env->{'If-Modified-Since'} and $incoming_key eq $key ) {
+         Jifty->log->debug("Returning 304 for CAS cached $domain:$name ($key)");
 -        Jifty->handler->apache->header_out( Status => 304 );
++        Jifty->web->response->header( Status => 304 );
+         return 304;
+     }
+ 
+     my $obj = Jifty::CAS->retrieve($domain, $key);
+ 
+     return $class->_serve_404( $domain, $name, "Unable to retrieve blob." )
+         if not defined $obj;
+ 
+     my $compression = '';
+     $compression = 'gzip' if $obj->metadata->{deflate}
+       && Jifty::View::Static::Handler->client_accepts_gzipped_content;
+ 
 -    Jifty->handler->apache->content_type($obj->metadata->{content_type});
++    Jifty->web->response->content_type($obj->metadata->{content_type});
+     Jifty::View::Static::Handler->send_http_header($compression, length($obj->content));
+ 
+     if ( $compression ) {
+         Jifty->log->debug("Sending gzipped squished $domain:$name ($key) from CAS");
 -        binmode STDOUT;
 -        print $obj->content_deflated;
++        Jifty->web->out($obj->content_deflated);
+     } else {
+         Jifty->log->debug("Sending squished $domain:$name ($key) from CAS");
 -        print $obj->content;
++        Jifty->web->out($obj->content);
+     }
+     return 200;
+ }
+ 
+ sub _serve_404 {
+     my ($class, $domain, $name, $msg) = @_;
+     $msg ||= '';
+     Jifty->log->error("Returning 404 for CAS cached $domain:$name.  $msg");
 -    Jifty->handler->apache->header_out( Status => 404 );
++    Jifty->web->response->header( Status => 404 );
+     return 404;
  }
  
  1;
diff --cc lib/Jifty/Test.pm
index d832cb5,952a436..0f13c71
--- a/lib/Jifty/Test.pm
+++ b/lib/Jifty/Test.pm
@@@ -14,6 -14,15 +14,11 @@@ use Hash::Merge
  use Digest::MD5 qw/md5_hex/;
  use Cwd qw/abs_path cwd/;
  
 -# this is required here because we want Test::HTTP::Server::Simple's
 -# END to be at the very last, later than Jifty::Test's
 -use Test::HTTP::Server::Simple;
 -
+ # Mechanize uses Test::LongString to report mismatches.  Increase the
+ # limit so we can see where errors come from more easily.
+ use Test::LongString;
+ $Test::LongString::Max = 128;
+ 
  =head1 NAME
  
  Jifty::Test - Jifty's test module

commit 6074ce55765df2a03c37e617d35d1785a1991516
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Fri Feb 5 15:13:14 2010 +0800

    Bump most testapp ConfigFileVersion.

diff --git a/t/TestApp-Collection-Select/etc/config.yml b/t/TestApp-Collection-Select/etc/config.yml
index 833635a..9175d5e 100644
--- a/t/TestApp-Collection-Select/etc/config.yml
+++ b/t/TestApp-Collection-Select/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp
   ApplicationName: TestApp
   ApplicationUUID: bf3d4130-6211-4acd-8496-3189acdc856b
-  ConfigFileVersion: 4
+  ConfigFileVersion: 5
   Database: 
     AutoUpgrade: 1
     CheckSchema: 1
diff --git a/t/TestApp-Dispatcher/etc/config.yml b/t/TestApp-Dispatcher/etc/config.yml
index 34afa77..5d46b62 100644
--- a/t/TestApp-Dispatcher/etc/config.yml
+++ b/t/TestApp-Dispatcher/etc/config.yml
@@ -1,6 +1,6 @@
 --- 
 framework: 
-  ConfigFileVersion: 4
+  ConfigFileVersion: 5
 
   ApplicationClass: TestApp::Dispatcher
   ApplicationName: TestApp-Dispatcher
diff --git a/t/TestApp-JiftyJS/etc/config.yml b/t/TestApp-JiftyJS/etc/config.yml
index a7c14cb..6ef467b 100644
--- a/t/TestApp-JiftyJS/etc/config.yml
+++ b/t/TestApp-JiftyJS/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp::JiftyJS
   ApplicationName: TestApp::JiftyJS
   ApplicationUUID: F43CA57E-A4BE-11DC-A07C-465A83BE23AB
-  ConfigFileVersion: 4
+  ConfigFileVersion: 5
   Database: 
     CheckSchema: 1
     Database: testapp_jiftyjs
diff --git a/t/TestApp-Mason/etc/config.yml b/t/TestApp-Mason/etc/config.yml
index 4f034c8..34d656f 100644
--- a/t/TestApp-Mason/etc/config.yml
+++ b/t/TestApp-Mason/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp::Mason
   ApplicationName: TestApp-Mason
   ApplicationUUID: 691A2590-F25E-11DD-9995-406635203BE5
-  ConfigFileVersion: 4
+  ConfigFileVersion: 5
   Database: 
     AutoUpgrade: 1
     CheckSchema: 1
diff --git a/t/TestApp-Notifications/etc/config.yml b/t/TestApp-Notifications/etc/config.yml
index 0177479..ee59991 100644
--- a/t/TestApp-Notifications/etc/config.yml
+++ b/t/TestApp-Notifications/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp
   ApplicationName: TestApp
   ApplicationUUID: F3F2F2C8-E9BB-11DE-AFD7-6AEE7828A805
-  ConfigFileVersion: 4
+  ConfigFileVersion: 5
   Database: 
     AutoUpgrade: 1
     CheckSchema: 1
diff --git a/t/TestApp-Plugin-ActorMetadata/etc/config.yml b/t/TestApp-Plugin-ActorMetadata/etc/config.yml
index dd53423..70ae7a4 100644
--- a/t/TestApp-Plugin-ActorMetadata/etc/config.yml
+++ b/t/TestApp-Plugin-ActorMetadata/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp::Plugin::ActorMetadata
   ApplicationName: TestApp::Plugin::ActorMetadata
   ApplicationUUID: C4418A2E-DE0B-11DD-96DC-F9E9C3E98ACD
-  ConfigFileVersion: 4
+  ConfigFileVersion: 5
   Database: 
     AutoUpgrade: 1
     CheckSchema: 1
diff --git a/t/TestApp-Plugin-AppPluginHasModels/etc/config.yml b/t/TestApp-Plugin-AppPluginHasModels/etc/config.yml
index b7e1fe0..2dfb89b 100644
--- a/t/TestApp-Plugin-AppPluginHasModels/etc/config.yml
+++ b/t/TestApp-Plugin-AppPluginHasModels/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp::Plugin::AppPluginHasModels
   ApplicationName: TestApp-Plugin-AppPluginHasModels
   ApplicationUUID: 646FD662-32DD-11DC-AD79-2A0157C3B83B
-  ConfigFileVersion: 2
+  ConfigFileVersion: 5
   Database: 
     CheckSchema: 1
     Database: testapp_plugin_apppluginhasmodels
diff --git a/t/TestApp-Plugin-CompressedCSSandJS/etc/config.yml b/t/TestApp-Plugin-CompressedCSSandJS/etc/config.yml
index 44a4101..80c5292 100644
--- a/t/TestApp-Plugin-CompressedCSSandJS/etc/config.yml
+++ b/t/TestApp-Plugin-CompressedCSSandJS/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp::Plugin::CompressedCSSandJS
   ApplicationName: TestApp::Plugin::CompressedCSSandJS
   ApplicationUUID: DC3B58E4-4F3C-11DC-9ECB-E5DB6F105773
-  ConfigFileVersion: 2
+  ConfigFileVersion: 5
   Database: 
     CheckSchema: 1
     Database: testapp_plugin_singlepage
diff --git a/t/TestApp-Plugin-OnClick/etc/config.yml b/t/TestApp-Plugin-OnClick/etc/config.yml
index 6ee9e0b..7fadd1a 100644
--- a/t/TestApp-Plugin-OnClick/etc/config.yml
+++ b/t/TestApp-Plugin-OnClick/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp::Plugin::OnClick
   ApplicationName: TestApp-Plugin-OnClick
   ApplicationUUID: 45E1B0FE-820A-11DC-9905-76B28F38D863
-  ConfigFileVersion: 4
+  ConfigFileVersion: 5
   Database: 
     CheckSchema: 1
     Database: testapp_plugin_onclick
diff --git a/t/TestApp-Plugin-SinglePage/etc/config.yml b/t/TestApp-Plugin-SinglePage/etc/config.yml
index c14e78e..3b4e1f0 100644
--- a/t/TestApp-Plugin-SinglePage/etc/config.yml
+++ b/t/TestApp-Plugin-SinglePage/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp::Plugin::SinglePage
   ApplicationName: TestApp::Plugin::SinglePage
   ApplicationUUID: DC3B58E4-4F3C-11DC-9ECB-E5DB6F105773
-  ConfigFileVersion: 2
+  ConfigFileVersion: 5
   Database: 
     CheckSchema: 1
     Database: testapp_plugin_singlepage
diff --git a/t/TestApp-Regions/etc/config.yml b/t/TestApp-Regions/etc/config.yml
index c1640a8..e188147 100644
--- a/t/TestApp-Regions/etc/config.yml
+++ b/t/TestApp-Regions/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp::Regions
   ApplicationName: TestApp-Regions
   ApplicationUUID: B2619C96-9EC7-11DD-8442-E9B62EB97401
-  ConfigFileVersion: 4
+  ConfigFileVersion: 5
   Database: 
     AutoUpgrade: 1
     CheckSchema: 1
diff --git a/t/TestApp-RestartServer/etc/config.yml b/t/TestApp-RestartServer/etc/config.yml
index 6188904..c8e82fd 100644
--- a/t/TestApp-RestartServer/etc/config.yml
+++ b/t/TestApp-RestartServer/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp::RestartServer
   ApplicationName: TestApp-RestartServer
   ApplicationUUID: 691A2590-F25E-11DD-9995-406635203BE5
-  ConfigFileVersion: 4
+  ConfigFileVersion: 5
   Database: 
     AutoUpgrade: 1
     CheckSchema: 1
diff --git a/t/TestApp-Template-Declare/etc/config.yml b/t/TestApp-Template-Declare/etc/config.yml
index 93c1e91..a73eeef 100644
--- a/t/TestApp-Template-Declare/etc/config.yml
+++ b/t/TestApp-Template-Declare/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp
   ApplicationName: TestApp
   ApplicationUUID: CE9AD926-F2A1-11DD-BB2C-5CD7FE13D77C
-  ConfigFileVersion: 4
+  ConfigFileVersion: 5
   Database: 
     AutoUpgrade: 1
     CheckSchema: 1
diff --git a/t/TestApp-Uploads/etc/config.yml b/t/TestApp-Uploads/etc/config.yml
index 4ac17d5..6c3faa7 100644
--- a/t/TestApp-Uploads/etc/config.yml
+++ b/t/TestApp-Uploads/etc/config.yml
@@ -4,7 +4,7 @@ framework:
   ApplicationClass: TestApp::Uploads
   ApplicationName: TestApp-Uploads
   ApplicationUUID: EE2D4328-FF2F-11DE-9789-0CDBEE916148
-  ConfigFileVersion: 4
+  ConfigFileVersion: 5
   Database: 
     AutoUpgrade: 1
     CheckSchema: 1

commit ace3cff19386702af03591d50d62947de0277bfd
Author: Chia-liang Kao <clkao at clkao.org>
Date:   Fri Feb 5 16:46:38 2010 +0800

    Replace all home-brew gzip handling code with Plack::Middleware::Deflater.

diff --git a/Makefile.PL b/Makefile.PL
index 3f37c24..efa4d13 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -69,8 +69,9 @@ requires('Module::Refresh');
 requires('Module::ScanDeps');
 requires('Object::Declare' => '0.13');
 requires('Params::Validate');
-requires('Plack' => '0.99_01'); # Plack::Loader Plack::Test Plack::Util
+requires('Plack' => '0.99_01'); # Plack::Loader Plack::Test Plack::Util Plack::Builder
 requires('Plack::Request');
+requires('Plack::Middleware::Deflater');
 requires('Scalar::Defer' => '0.12');
 requires('Shell::Command');
 requires('String::BufferStack' => '1.12');
diff --git a/lib/Jifty/CAS.pm b/lib/Jifty/CAS.pm
index 1fc03ba..8ff985c 100644
--- a/lib/Jifty/CAS.pm
+++ b/lib/Jifty/CAS.pm
@@ -13,7 +13,6 @@ Jifty::CAS - Jifty's Content-Addressable Storage facility
   my $key = Jifty::CAS->publish('js' => 'all', $content,
                       { hash_with => $content, # default behaviour
                         content_type => 'application/x-javascript',
-                        deflate => 1
                       });
 
   $ie_key = Jifty::CAS->publish('js' => 'ie-only', $ie_content,
@@ -67,9 +66,7 @@ assumes that content is served to clients from the CAS with the CAS key (an MD5
 sum) as the filename or part of it.
 
 The C<content_type> key in the requested object's metadata is expected to be
-set and is used for the HTTP response.  If a true value is set for C<deflate>
-in the object's metadata, then this method will serve gzipped content if the
-client supports it.
+set and is used for the HTTP response.
 
 This method is usually called from a dispatcher rule.  Returns the HTTP status
 code set by this method (possibly for your use in the dispatcher).
@@ -94,20 +91,12 @@ sub serve_by_name {
     return $class->_serve_404( $domain, $name, "Unable to retrieve blob." )
         if not defined $obj;
 
-    my $compression = '';
-    $compression = 'gzip' if $obj->metadata->{deflate}
-      && Jifty::View::Static::Handler->client_accepts_gzipped_content;
-
     Jifty->web->response->content_type($obj->metadata->{content_type});
-    Jifty::View::Static::Handler->send_http_header($compression, length($obj->content));
-
-    if ( $compression ) {
-        Jifty->log->debug("Sending gzipped squished $domain:$name ($key) from CAS");
-        Jifty->web->out($obj->content_deflated);
-    } else {
-        Jifty->log->debug("Sending squished $domain:$name ($key) from CAS");
-        Jifty->web->out($obj->content);
-    }
+    Jifty::View::Static::Handler->send_http_header('', length($obj->content));
+
+    Jifty->log->debug("Sending squished $domain:$name ($key) from CAS");
+    Jifty->web->out($obj->content);
+
     return 200;
 }
 
diff --git a/lib/Jifty/CAS/Blob.pm b/lib/Jifty/CAS/Blob.pm
index 2f7ffaf..41f3902 100644
--- a/lib/Jifty/CAS/Blob.pm
+++ b/lib/Jifty/CAS/Blob.pm
@@ -35,21 +35,12 @@ creates a new object.  Possible special keys in the metadata include:
 Provides the data to hash to generate the address.  If no C<hash_with>
 is provided, the content itself is hashed.
 
-=item deflate
-
-If set to a true value, deflates the content using
-L<Compress::Zlib/memGzip>, and stores that in L</content_deflated>.
-
 =back
 
 =head2 content
 
 Returns the content of the blob.
 
-=head2 content_deflated
-
-If L</deflate> in the metadata was set, contains the deflated content.
-
 =head2 metadata
 
 Returns a hashref of metadata.
@@ -74,14 +65,4 @@ sub new {
     return $self;
 }
 
-sub content_deflated {
-    my $self = shift;
-    return unless $self->metadata->{deflate};
-
-    $self->{content_deflated} = Compress::Zlib::memGzip( $self->content )
-        unless exists $self->{content_deflated};
-
-    return $self->{content_deflated};
-}
-
 1;
diff --git a/lib/Jifty/Handler.pm b/lib/Jifty/Handler.pm
index 2a04d24..377b07d 100644
--- a/lib/Jifty/Handler.pm
+++ b/lib/Jifty/Handler.pm
@@ -28,6 +28,8 @@ use Jifty::View::Declare::Handler ();
 use Class::Trigger;
 use String::BufferStack;
 use Plack::Request;
+use Plack::Builder;
+use Plack::Util;
 
 __PACKAGE__->mk_accessors(qw(dispatcher _view_handlers stash buffer));
 
@@ -120,7 +122,24 @@ Returns a closure for L<PSGI> application.
 
 sub psgi_app {
     my $self = shift;
-    return sub { $self->handle_request(@_) };
+
+    my $app = sub { $self->handle_request(@_) };
+
+    # allow plugin to wrap $app
+    builder {
+        enable 'Deflater';
+        enable sub { my $app = shift;
+                     sub { my $env = shift;
+                           my $res = $app->($env);
+                           my $h = Plack::Util::headers($res->[1]);
+                           my $type = $h->get('Content-Type')
+                               or return $res;
+                           delete $env->{HTTP_ACCEPT_ENCODING}
+                               unless $type =~ m|application/x-javascript| || $type =~ m|^text/|;
+                           $res }
+                 };
+        $app;
+    };
 }
 
 =head2 handle_request
diff --git a/lib/Jifty/Plugin/CompressedCSSandJS.pm b/lib/Jifty/Plugin/CompressedCSSandJS.pm
index c799a48..4d9d3f1 100644
--- a/lib/Jifty/Plugin/CompressedCSSandJS.pm
+++ b/lib/Jifty/Plugin/CompressedCSSandJS.pm
@@ -21,7 +21,6 @@ Jifty::Plugin::CompressedCSSandJS - Compression of CSS and javascript files
         css: 1
         jsmin: /path/to/jsmin
         cdn: 'http://yourcdn.for.static.prefix/'
-        gzip: 1
         skipped_js:
             - complex.js
         generate_early: 1
@@ -40,10 +39,6 @@ L<http://www.crockford.com/javascript/jsmin.html>.
 Note that you will need to use C<ConfigFileVersion> 2 to be able to
 configure jsmin feature.
 
-The gzip configuration directive, which defaults to enabled, instructs
-Jifty to transparently gzip css and js files as they're served if the client
-indicates it supports that feature.
-
 skipped_js is a list of js that you don't want to compress for some reason.
 
 generate_early tells the plugin to compress the CSS and JS at process start
@@ -53,7 +48,7 @@ by default.
 
 =cut
 
-__PACKAGE__->mk_accessors(qw(css js jsmin cdn gzip_enabled skipped_js generate_early));
+__PACKAGE__->mk_accessors(qw(css js jsmin cdn skipped_js generate_early));
 
 =head2 init
 
@@ -69,7 +64,6 @@ sub init {
 
     my %opt  = @_;
     $self->css( $opt{css} );
-    $self->gzip_enabled( exists $opt{gzip} ? $opt{gzip} : 1);
     $self->js( $opt{js} );
     $self->jsmin( $opt{jsmin} );
     $self->cdn( $opt{cdn} || '');
@@ -118,12 +112,6 @@ sub css_enabled {
     defined $self->css ? $self->css : 1;
 }
 
-=head2 gzip_enabled
-
-Returns whether gzipping is enabled (which it is by default)
-
-=cut
-
 sub _include_javascript {
     my $self = shift;
 
@@ -175,7 +163,7 @@ sub generate_css {
     );
 
     Jifty::CAS->publish( 'ccjs', 'css-all', $css,
-        { content_type => 'text/css', deflate => $self->gzip_enabled, time => time() } );
+        { content_type => 'text/css', time => time() } );
 }
 
 
@@ -222,7 +210,7 @@ sub _generate_javascript {
         }
 
     Jifty::CAS->publish( 'ccjs', 'js-all', $js,
-        { content_type => 'application/x-javascript', deflate => $self->gzip_enabled, time => time() } );
+        { content_type => 'application/x-javascript', time => time() } );
 }
 
 =head2 minify_js \$js
diff --git a/lib/Jifty/Test/WWW/Mechanize.pm b/lib/Jifty/Test/WWW/Mechanize.pm
index 52eec75..26aa8b1 100644
--- a/lib/Jifty/Test/WWW/Mechanize.pm
+++ b/lib/Jifty/Test/WWW/Mechanize.pm
@@ -51,6 +51,20 @@ sub new {
     return $self;
 }
 
+=head2 request
+
+We override mechanize's defualt request method so accept-encoding is
+not set to gzip by default.
+
+=cut
+
+sub request {
+    my ($self, $req) = @_;
+    $req->header( 'Accept-Encoding', 'identity' )
+        unless $req->header( 'Accept-Encoding' );
+    return $self->SUPER::request($req);
+}
+
 =head2 moniker_for ACTION, FIELD1 => VALUE1, FIELD2 => VALUE2
 
 Finds the moniker of the first action of type I<ACTION> whose
diff --git a/lib/Jifty/View/Static/Handler.pm b/lib/Jifty/View/Static/Handler.pm
index 4f63e65..9198410 100644
--- a/lib/Jifty/View/Static/Handler.pm
+++ b/lib/Jifty/View/Static/Handler.pm
@@ -2,7 +2,6 @@ use warnings;
 use strict;
 use File::MMagic ();
 use MIME::Types ();
-use Compress::Zlib ();
 use HTTP::Date ();
 
 package Jifty::View::Static::Handler;
@@ -17,6 +16,8 @@ Jifty::View::Static::Handler - Jifty view handler for static files
 
 =head1 DESCRIPTION
 
+This is deprecated and is being port to a stack of plack middleware and plack::app::file
+
 This class takes care of serving out static files for a Jifty application. 
 
 When fully operational, it will use an algorithm along the lines of the following:
@@ -102,32 +103,9 @@ sub handle_request {
         return $self->send_not_modified
             unless $file_info[9] > HTTP::Date::str2time($since);
     }
-    my $mime_type = $self->mime_type($local_path);
-
-    # XXX: gzipped sendfile is printing to STDOUT.
-    # port this to psgi or plack::app::file.
-    # gzip should be a separate middleware as well.
-    if ( 0 && $self->client_accepts_gzipped_content and $mime_type =~ m!^(text/|application/x-javascript)! ) {
-        return $self->send_file($local_path, $mime_type, 'gzip');
-    } else {
-        return $self->send_file($local_path, $mime_type, 'uncompressed');
-    }
-
-}
-
-
-=head2 client_accepts_gzipped_content
-
-Returns true if it looks like the client accepts gzip encoding. Otherwise, returns false.
-
-
-=cut
 
+    return $self->send_file($local_path, $self->mime_type($local_path));
 
-sub client_accepts_gzipped_content {
-    my $self = shift;
-    no warnings 'uninitialized';
-    return Jifty->web->request->header('Accept-Encoding') =~ /\bgzip\b/;
 }
 
 
@@ -204,13 +182,10 @@ sub mime_type {
 }
 
 
-=head2 send_file $path $mimetype $compression
+=head2 send_file $path $mimetype
 
 Print C<$path> to STDOUT (the client), identified with a mimetype of C<$mimetype>.
 
-If C<$compression> is C<gzip>, gzip the output stream.
-
-
 =cut
 
 
@@ -218,7 +193,6 @@ sub send_file {
     my $self        = shift;
     my $local_path  = shift;
     my $mime_type   = shift;
-    my $compression = shift;
 
     my $fh = IO::File->new( $local_path, 'r' );
     if ( defined $fh ) {
@@ -232,18 +206,10 @@ sub send_file {
 
         my @file_info = stat($local_path);
         Jifty->web->response->content_type($mime_type);
-        $self->send_http_header( $compression, $file_info[7], $file_info[9] );
+        $self->send_http_header( '', $file_info[7], $file_info[9] );
 
-        if ( $compression eq 'gzip' ) {
-            local $/;
-            binmode STDOUT;
+        Jifty->web->response->content($fh);
 
-            # XXX TODO: Cache this
-            print STDOUT Compress::Zlib::memGzip(<$fh>);
-        }
-        else {
-            Jifty->web->response->content($fh);
-        }
         return 1;
     }
     else {
@@ -254,13 +220,13 @@ sub send_file {
 =head2 send_http_header [COMPRESSION, LENGTH, LAST_MODIFIED]
 
 Sends appropriate cache control and expiration headers such that the
-client will cache the content.
+client will cache the content.  COMPRESSION is deprecated
 
 =cut
 
 sub send_http_header {
     my $self = shift;
-    my ($compression, $length, $modified) = @_;
+    my (undef, $length, $modified) = @_;
     my $now    = time();
     my $response = Jifty->web->response;
     $response->status( 200 );
@@ -271,11 +237,6 @@ sub send_http_header {
 
     $response->header(
       'Last-Modified' => HTTP::Date::time2str( $modified ) ) if $modified;
-
-    $response->header( 'Content-Length' => $length )
-      unless ( $compression eq 'gzip' );
-    $response->header( 'Content-Encoding' => "gzip" )
-      if ( $compression eq 'gzip' );
 }
 
 
diff --git a/t/TestApp/t/10-compress.t b/t/TestApp/t/10-compress.t
index a14e087..286d357 100644
--- a/t/TestApp/t/10-compress.t
+++ b/t/TestApp/t/10-compress.t
@@ -17,15 +17,24 @@ my $server  = Jifty::Test->make_server;
 my $URL     = $server->started_ok;
 
 my $mech    = Jifty::Test::WWW::Mechanize->new();
-$mech->get_ok($URL);
+my $request = HTTP::Request->new( GET => "$URL/", ['Accept-Encoding' => 'identity'] );
+
+my $response = $mech->request($request);
+
 my $expected = $mech->response->content;
 like($expected, qr/Jifty Test Application/);
 
-SKIP: {
-skip "blah", 2;
-my $request = HTTP::Request->new( GET => "$URL/", ['Accept-Encoding' => 'gzip'] );
-my $response = $mech->request( $request );
+# now gzip
+
+$request = HTTP::Request->new( GET => "$URL/", ['Accept-Encoding' => 'gzip'] );
+$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/);
-}
+
+
+$request = HTTP::Request->new( GET => "$URL/static/images/pony.jpg", ['Accept-Encoding' => 'gzip'] );
+$response = $mech->request( $request );
+
+is($response->header('Content-Encoding'), undef, 'image are not compressed');
+

-----------------------------------------------------------------------


More information about the Jifty-commit mailing list