Subject: | Compress::Deflate fails when $c->response->body is a ref |
I have attached a fix..It fails because even though it does this:
my $body = $c->response->body;
eval { local $/; $body = <$body> } if ref $body;
It does not actually return $body, it still returns $c->response->body
( $out, $status ) = $d->deflate( $c->response->body );
I have attached a patch. Also, the Gzip plugin was setting an incorrect
content length for this same reason.
--
Andrew Bryan
abryan+bc@pangeamedia.com
Subject: | Catalyst-Plugin-Compress-Zlib.diff |
diff -ru Catalyst-Plugin-Compress-Zlib-0.04.orig/lib/Catalyst/Plugin/Compress/Deflate.pm Catalyst-Plugin-Compress-Zlib-0.04/lib/Catalyst/Plugin/Compress/Deflate.pm
--- Catalyst-Plugin-Compress-Zlib-0.04.orig/lib/Catalyst/Plugin/Compress/Deflate.pm 2009-11-19 20:22:49.000000000 -0500
+++ Catalyst-Plugin-Compress-Zlib-0.04/lib/Catalyst/Plugin/Compress/Deflate.pm 2010-07-01 15:45:06.738149038 -0400
@@ -43,7 +43,7 @@
my $body = $c->response->body;
eval { local $/; $body = <$body> } if ref $body;
die "Response body is an unsupported kind of reference" if ref $body;
- ( $out, $status ) = $d->deflate( $c->response->body );
+ ( $out, $status ) = $d->deflate( $body );
unless ( $status == Compress::Zlib::Z_OK() ) {
die("Deflation failed. Error: $status");
diff -ru Catalyst-Plugin-Compress-Zlib-0.04.orig/lib/Catalyst/Plugin/Compress/Gzip.pm Catalyst-Plugin-Compress-Zlib-0.04/lib/Catalyst/Plugin/Compress/Gzip.pm
--- Catalyst-Plugin-Compress-Zlib-0.04.orig/lib/Catalyst/Plugin/Compress/Gzip.pm 2009-11-19 20:22:42.000000000 -0500
+++ Catalyst-Plugin-Compress-Zlib-0.04/lib/Catalyst/Plugin/Compress/Gzip.pm 2010-07-01 15:45:37.792387158 -0400
@@ -35,7 +35,7 @@
die "Response body is an unsupported kind of reference" if ref $body;
$c->response->body( Compress::Zlib::memGzip( $body ) );
- $c->response->content_length( length( $c->response->body ) );
+ $c->response->content_length( length( $body ) );
$c->response->content_encoding('gzip');
$c->response->headers->push_header( 'Vary', 'Accept-Encoding' );