Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

rename no-gzip to no-compress

  • Loading branch information...
commit b6d28d433ebd1e6f4a79f6fe12461648dd19d41e 1 parent 2537c92
Masahiro Nagano authored
20 README
@@ -7,7 +7,16 @@ SYNOPSIS
7 7 my $app = shift;
8 8 sub {
9 9 my $env = shift;
10   - delete $env->{HTTP_ACCEPT_ENCODING} if $env->{HTTP_USER_AGENT} =~ m!^Mozilla/4.0[678]!; #Nescape has some problem
  10 + my $ua = $env->{HTTP_USER_AGENT} || '';
  11 + # Netscape has some problem
  12 + $env->{"psgix.gzip-only-text/html"} = 1 if $ua =~ m!^Mozilla/4!;
  13 + # Netscape 4.06-4.08 have some more problems
  14 + $env->{"psgix.no-gzip"} = 1 if $ua =~ m!^Mozilla/4\.0[678]!;
  15 + # MSIE (7|8) masquerades as Netscape, but it is fine
  16 + if ( $ua =~ m!\bMSIE (?:7|8)! ) {
  17 + $env->{"psgix.no-gzip"} = 0;
  18 + $env->{"psgix.gzip-only-text/html"} = 0;
  19 + }
11 20 $app->($env);
12 21 }
13 22 };
@@ -39,6 +48,13 @@ CONFIGURATIONS
39 48
40 49 Add "User-Agent" to Vary header.
41 50
  51 +ENVIRONMENT VALUE
  52 + psgix.no-gzip
  53 + Do not apply deflater
  54 +
  55 + psgix.gzip-only-text/html
  56 + apply deflater only if content_type is "text/html"
  57 +
42 58 LICENSE
43 59 This software is licensed under the same terms as Perl itself.
44 60
@@ -46,5 +62,5 @@ AUTHOR
46 62 Tatsuhiko Miyagawa
47 63
48 64 SEE ALSO
49   - Plack
  65 + Plack, <http://httpd.apache.org/docs/2.2/en/mod/mod_deflate.html>
50 66
16 lib/Plack/Middleware/Deflater.pm
@@ -55,12 +55,12 @@ sub call {
55 55 push @vary, 'User-Agent' if $self->vary_user_agent;
56 56 $h->set('Vary' => join(",", @vary));
57 57
58   - # some browsers might have problems, so set no-gzip
59   - return if $env->{"psgix.no-gzip"};
  58 + # some browsers might have problems, so set no-compress
  59 + return if $env->{"psgix.no-compress"};
60 60
61 61 # Some browsers might have problems with content types
62   - # other than text/html, so set gzip-only-text/html
63   - if ( $env->{"psgix.gzip-only-text/html"} ) {
  62 + # other than text/html, so set compress-only-text/html
  63 + if ( $env->{"psgix.compress-only-text/html"} ) {
64 64 return if $content_type ne 'text/html';
65 65 }
66 66
@@ -139,7 +139,7 @@ Plack::Middleware::Deflater - Compress response body with Gzip or Deflate
139 139 $app->($env);
140 140 }
141 141 };
142   - enable "Deflater"
  142 + enable "Deflater",
143 143 content_type => ['text/css','text/html','text/javascript','application/javascript'],
144 144 vary_user_agent => 1;
145 145
@@ -178,13 +178,13 @@ Add "User-Agent" to Vary header.
178 178
179 179 =over 4
180 180
181   -=item psgix.no-gzip
  181 +=item psgix.no-compress
182 182
183 183 Do not apply deflater
184 184
185   -=item psgix.gzip-only-text/html
  185 +=item psgix.compress-only-text/html
186 186
187   -apply deflater only if content_type is "text/html"
  187 +Apply deflater only if content_type is "text/html"
188 188
189 189 =back
190 190
4 t/xno-gzip.t → t/xno-compress.t
@@ -14,7 +14,7 @@ my $app = builder {
14 14 my $cb = shift;
15 15 sub {
16 16 my $env = shift;
17   - $env->{"psgix.no-gzip"} = 1;
  17 + $env->{"psgix.no-compress"} = 1;
18 18 $cb->($env);
19 19 }
20 20 };
@@ -40,7 +40,7 @@ my $app2 = builder {
40 40 my $cb = shift;
41 41 sub {
42 42 my $env = shift;
43   - $env->{"psgix.gzip-only-text/html"} = 1;
  43 + $env->{"psgix.compress-only-text/html"} = 1;
44 44 $cb->($env);
45 45 }
46 46 };
7 xt/podspell.t
@@ -7,3 +7,10 @@ all_pod_files_spelling_ok('lib');
7 7 __DATA__
8 8 Tatsuhiko
9 9 Miyagawa
  10 +Deflater
  11 +Plack
  12 +chunked
  13 +deflater
  14 +middleware
  15 +psgix
  16 +

0 comments on commit b6d28d4

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