Skip to content

Commit

Permalink
rename no-gzip to no-compress
Browse files Browse the repository at this point in the history
  • Loading branch information
kazeburo committed Feb 1, 2011
1 parent 2537c92 commit b6d28d4
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 12 deletions.
20 changes: 18 additions & 2 deletions README
Expand Up @@ -7,7 +7,16 @@ SYNOPSIS
my $app = shift; my $app = shift;
sub { sub {
my $env = shift; 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); $app->($env);
} }
}; };
Expand Down Expand Up @@ -39,12 +48,19 @@ CONFIGURATIONS


Add "User-Agent" to Vary header. 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 LICENSE
This software is licensed under the same terms as Perl itself. This software is licensed under the same terms as Perl itself.


AUTHOR AUTHOR
Tatsuhiko Miyagawa Tatsuhiko Miyagawa


SEE ALSO SEE ALSO
Plack Plack, <http://httpd.apache.org/docs/2.2/en/mod/mod_deflate.html>


16 changes: 8 additions & 8 deletions lib/Plack/Middleware/Deflater.pm
Expand Up @@ -55,12 +55,12 @@ sub call {
push @vary, 'User-Agent' if $self->vary_user_agent; push @vary, 'User-Agent' if $self->vary_user_agent;
$h->set('Vary' => join(",", @vary)); $h->set('Vary' => join(",", @vary));


# some browsers might have problems, so set no-gzip # some browsers might have problems, so set no-compress
return if $env->{"psgix.no-gzip"}; return if $env->{"psgix.no-compress"};


# Some browsers might have problems with content types # Some browsers might have problems with content types
# other than text/html, so set gzip-only-text/html # other than text/html, so set compress-only-text/html
if ( $env->{"psgix.gzip-only-text/html"} ) { if ( $env->{"psgix.compress-only-text/html"} ) {
return if $content_type ne 'text/html'; return if $content_type ne 'text/html';
} }


Expand Down Expand Up @@ -139,7 +139,7 @@ Plack::Middleware::Deflater - Compress response body with Gzip or Deflate
$app->($env); $app->($env);
} }
}; };
enable "Deflater" enable "Deflater",
content_type => ['text/css','text/html','text/javascript','application/javascript'], content_type => ['text/css','text/html','text/javascript','application/javascript'],
vary_user_agent => 1; vary_user_agent => 1;
Expand Down Expand Up @@ -178,13 +178,13 @@ Add "User-Agent" to Vary header.
=over 4 =over 4
=item psgix.no-gzip =item psgix.no-compress
Do not apply deflater 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 =back
Expand Down
4 changes: 2 additions & 2 deletions t/xno-gzip.t → t/xno-compress.t
Expand Up @@ -14,7 +14,7 @@ my $app = builder {
my $cb = shift; my $cb = shift;
sub { sub {
my $env = shift; my $env = shift;
$env->{"psgix.no-gzip"} = 1; $env->{"psgix.no-compress"} = 1;
$cb->($env); $cb->($env);
} }
}; };
Expand All @@ -40,7 +40,7 @@ my $app2 = builder {
my $cb = shift; my $cb = shift;
sub { sub {
my $env = shift; my $env = shift;
$env->{"psgix.gzip-only-text/html"} = 1; $env->{"psgix.compress-only-text/html"} = 1;
$cb->($env); $cb->($env);
} }
}; };
Expand Down
7 changes: 7 additions & 0 deletions xt/podspell.t
Expand Up @@ -7,3 +7,10 @@ all_pod_files_spelling_ok('lib');
__DATA__ __DATA__
Tatsuhiko Tatsuhiko
Miyagawa Miyagawa
Deflater
Plack
chunked
deflater
middleware
psgix

0 comments on commit b6d28d4

Please sign in to comment.