line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Plack::Middleware::RequestHeaders; |
2
|
|
|
|
|
|
|
# ABSTRACT: modify HTTP request headers |
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
our $VERSION = '0.05'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
2
|
|
|
2
|
|
21001
|
use strict; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
73
|
|
7
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
57
|
|
8
|
2
|
|
|
2
|
|
955
|
use Plack::Util (); |
|
2
|
|
|
|
|
15050
|
|
|
2
|
|
|
|
|
48
|
|
9
|
2
|
|
|
2
|
|
852
|
use Plack::Util::Accessor qw/set unset/; |
|
2
|
|
|
|
|
246
|
|
|
2
|
|
|
|
|
17
|
|
10
|
|
|
|
|
|
|
|
11
|
2
|
|
|
2
|
|
116
|
use parent 'Plack::Middleware'; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
13
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub build_req_header_key { |
14
|
4
|
|
|
4
|
0
|
13
|
my ( $self, $key ) = @_; |
15
|
4
|
|
|
|
|
16
|
my $hname = join(q{_}, split(/\-/, uc $key)); |
16
|
4
|
100
|
|
|
|
33
|
return $hname =~ m{CONTENT\_(LENGTH|TYPE)} ? $hname : q{HTTP_} . $hname; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub call { |
20
|
1
|
|
|
1
|
1
|
147
|
my ( $self, $env ) = @_; |
21
|
|
|
|
|
|
|
|
22
|
1
|
50
|
|
|
|
5
|
if ( my $set_headers = $self->set ) { |
23
|
|
|
|
|
|
|
Plack::Util::header_iter($set_headers, sub { |
24
|
3
|
|
|
3
|
|
18
|
my ( $key, $val ) = @_; |
25
|
3
|
|
|
|
|
8
|
$env->{ $self->build_req_header_key($key) } = $val; |
26
|
1
|
|
|
|
|
102
|
}); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
1
|
50
|
|
|
|
7
|
delete $env->{ $self->build_req_header_key($_) } for @{$self->unset || []}; |
|
1
|
|
|
|
|
4
|
|
30
|
|
|
|
|
|
|
|
31
|
1
|
|
|
|
|
8
|
return $self->app->($env); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
1; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
__END__ |