line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::ChromeFrame; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
25185
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
83
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
62
|
|
5
|
2
|
|
|
2
|
|
930
|
use parent qw(Plack::Middleware); |
|
2
|
|
|
|
|
290
|
|
|
2
|
|
|
|
|
15
|
|
6
|
|
|
|
|
|
|
|
7
|
2
|
|
|
2
|
|
26223
|
use Plack::Request; |
|
2
|
|
|
|
|
133332
|
|
|
2
|
|
|
|
|
78
|
|
8
|
2
|
|
|
2
|
|
18
|
use Plack::Util; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
476
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
11
|
|
|
|
|
|
|
$VERSION = eval $VERSION; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub call { |
14
|
4
|
|
|
4
|
1
|
32524
|
my ($self, $env) = @_; |
15
|
|
|
|
|
|
|
|
16
|
4
|
|
|
|
|
30
|
my $req = Plack::Request->new($env); |
17
|
4
|
|
|
|
|
45
|
my $ua = $req->user_agent; |
18
|
|
|
|
|
|
|
|
19
|
4
|
|
|
|
|
605
|
my $chromeframe = 0; |
20
|
4
|
100
|
66
|
|
|
46
|
if ($ua and $ua =~ /MSIE/ and $ua !~ /Opera/) { |
|
|
|
100
|
|
|
|
|
21
|
2
|
100
|
|
|
|
10
|
if ($ua =~ /chromeframe/) { |
22
|
1
|
|
|
|
|
3
|
$chromeframe = 1; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
else { |
25
|
1
|
|
|
|
|
6
|
my $res = $req->new_response; |
26
|
1
|
|
|
|
|
2621
|
$res->redirect('http://www.google.com/chromeframe'); |
27
|
1
|
|
|
|
|
107
|
return $res->finalize; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
3
|
|
|
|
|
17
|
my $res = $self->app->($env); |
32
|
|
|
|
|
|
|
$self->response_cb($res, sub { |
33
|
3
|
100
|
|
3
|
|
67
|
return unless $chromeframe; |
34
|
1
|
|
|
|
|
8
|
my $h = Plack::Util::headers($_[0]->[1]); |
35
|
1
|
|
|
|
|
53
|
$h->set('X-UA-Compatible' => 'chrome=1'); |
36
|
3
|
|
|
|
|
138
|
}); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
1; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
__END__ |