Skip to content
Browse files

rename no-gzip to no-compress

  • Loading branch information...
1 parent 2537c92 commit b6d28d433ebd1e6f4a79f6fe12461648dd19d41e @kazeburo committed Feb 1, 2011
Showing with 35 additions and 12 deletions.
  1. +18 −2 README
  2. +8 −8 lib/Plack/Middleware/Deflater.pm
  3. +2 −2 t/{xno-gzip.t → xno-compress.t}
  4. +7 −0 xt/podspell.t
View
20 README
@@ -7,7 +7,16 @@ SYNOPSIS
my $app = shift;
sub {
my $env = shift;
- delete $env->{HTTP_ACCEPT_ENCODING} if $env->{HTTP_USER_AGENT} =~ m!^Mozilla/4.0[678]!; #Nescape has some problem
+ my $ua = $env->{HTTP_USER_AGENT} || '';
+ # Netscape has some problem
+ $env->{"psgix.gzip-only-text/html"} = 1 if $ua =~ m!^Mozilla/4!;
+ # Netscape 4.06-4.08 have some more problems
+ $env->{"psgix.no-gzip"} = 1 if $ua =~ m!^Mozilla/4\.0[678]!;
+ # MSIE (7|8) masquerades as Netscape, but it is fine
+ if ( $ua =~ m!\bMSIE (?:7|8)! ) {
+ $env->{"psgix.no-gzip"} = 0;
+ $env->{"psgix.gzip-only-text/html"} = 0;
+ }
$app->($env);
}
};
@@ -39,12 +48,19 @@ CONFIGURATIONS
Add "User-Agent" to Vary header.
+ENVIRONMENT VALUE
+ psgix.no-gzip
+ Do not apply deflater
+
+ psgix.gzip-only-text/html
+ apply deflater only if content_type is "text/html"
+
LICENSE
This software is licensed under the same terms as Perl itself.
AUTHOR
Tatsuhiko Miyagawa
SEE ALSO
- Plack
+ Plack, <http://httpd.apache.org/docs/2.2/en/mod/mod_deflate.html>
View
16 lib/Plack/Middleware/Deflater.pm
@@ -55,12 +55,12 @@ sub call {
push @vary, 'User-Agent' if $self->vary_user_agent;
$h->set('Vary' => join(",", @vary));
- # some browsers might have problems, so set no-gzip
- return if $env->{"psgix.no-gzip"};
+ # some browsers might have problems, so set no-compress
+ return if $env->{"psgix.no-compress"};
# Some browsers might have problems with content types
- # other than text/html, so set gzip-only-text/html
- if ( $env->{"psgix.gzip-only-text/html"} ) {
+ # other than text/html, so set compress-only-text/html
+ if ( $env->{"psgix.compress-only-text/html"} ) {
return if $content_type ne 'text/html';
}
@@ -139,7 +139,7 @@ Plack::Middleware::Deflater - Compress response body with Gzip or Deflate
$app->($env);
}
};
- enable "Deflater"
+ enable "Deflater",
content_type => ['text/css','text/html','text/javascript','application/javascript'],
vary_user_agent => 1;
@@ -178,13 +178,13 @@ Add "User-Agent" to Vary header.
=over 4
-=item psgix.no-gzip
+=item psgix.no-compress
Do not apply deflater
-=item psgix.gzip-only-text/html
+=item psgix.compress-only-text/html
-apply deflater only if content_type is "text/html"
+Apply deflater only if content_type is "text/html"
=back
View
4 t/xno-gzip.t → t/xno-compress.t
@@ -14,7 +14,7 @@ my $app = builder {
my $cb = shift;
sub {
my $env = shift;
- $env->{"psgix.no-gzip"} = 1;
+ $env->{"psgix.no-compress"} = 1;
$cb->($env);
}
};
@@ -40,7 +40,7 @@ my $app2 = builder {
my $cb = shift;
sub {
my $env = shift;
- $env->{"psgix.gzip-only-text/html"} = 1;
+ $env->{"psgix.compress-only-text/html"} = 1;
$cb->($env);
}
};
View
7 xt/podspell.t
@@ -7,3 +7,10 @@ all_pod_files_spelling_ok('lib');
__DATA__
Tatsuhiko
Miyagawa
+Deflater
+Plack
+chunked
+deflater
+middleware
+psgix
+

0 comments on commit b6d28d4

Please sign in to comment.
Something went wrong with that request. Please try again.