Subject: | Compress JSON output |
According to RFC 4627, JSON output should be served with the content type
application/json. If it is, this plugin ought to compress it.
See attached patch.
Subject: | 0001-Compress-JSON-output.patch |
From 5e4e412fc1b6a6ec95dce16805271ea44db769f0 Mon Sep 17 00:00:00 2001
From: Michael Hendricks <michael@ndrix.org>
Date: Wed, 15 Oct 2008 14:38:06 -0600
Subject: [PATCH] Compress JSON output
According to RFC 4627, JSON output should be served with the content
type application/json. If it is, this plugin ought to compress it.
---
lib/Catalyst/Plugin/Compress/Deflate.pm | 2 +-
lib/Catalyst/Plugin/Compress/Gzip.pm | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/lib/Catalyst/Plugin/Compress/Deflate.pm b/lib/Catalyst/Plugin/Compress/Deflate.pm
index a08b8bc..b1e41c1 100644
--- a/lib/Catalyst/Plugin/Compress/Deflate.pm
+++ b/lib/Catalyst/Plugin/Compress/Deflate.pm
@@ -19,7 +19,7 @@ sub finalize {
return $c->NEXT::finalize;
}
- unless ( $c->response->content_type =~ /^text|xml$|javascript$/ ) {
+ unless ( $c->response->content_type =~ /^text|xml$|javascript$|json$/ ) {
return $c->NEXT::finalize;
}
diff --git a/lib/Catalyst/Plugin/Compress/Gzip.pm b/lib/Catalyst/Plugin/Compress/Gzip.pm
index 10743d1..5d48958 100644
--- a/lib/Catalyst/Plugin/Compress/Gzip.pm
+++ b/lib/Catalyst/Plugin/Compress/Gzip.pm
@@ -19,7 +19,7 @@ sub finalize {
return $c->NEXT::finalize;
}
- unless ( $c->response->content_type =~ /^text|xml$|javascript$/ ) {
+ unless ( $c->response->content_type =~ /^text|xml$|javascript$|json$/ ) {
return $c->NEXT::finalize;
}
--
1.6.0.2.307.gc4275