| 1 | package Plack::Middleware::RequestHeaders; | ||||||||||||
| 2 | # ABSTRACT: modify HTTP request headers | ||||||||||||
| 3 | |||||||||||||
| 4 | 2 | our $VERSION = '0.05'; # VERSION | |||||||||||
| 5 | |||||||||||||
| 6 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | 2 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 8 | 2 | ▶ | use Plack::Util (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 2 | ▶ | use Plack::Util::Accessor qw/set unset/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | |||||||||||||
| 11 | 2 | ▶ | use parent 'Plack::Middleware'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 12 | |||||||||||||
| 13 | 4 | ▶ | sub build_req_header_key { | ||||||||||
|
Subroutine
build_req_header_key: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 14 | 4 | my ( $self, $key ) = @_; | |||||||||||
| 15 | 4 | my $hname = join(q{_}, split(/\-/, uc $key)); | |||||||||||
| 16 | 4 | ▶ | return $hname =~ m{CONTENT\_(LENGTH|TYPE)} ? $hname : q{HTTP_} . $hname; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 17 | } | ||||||||||||
| 18 | |||||||||||||
| 19 | 1 | ▶ | sub call { | ||||||||||
|
Subroutine
call: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||
| 20 | 1 | my ( $self, $env ) = @_; | |||||||||||
| 21 | |||||||||||||
| 22 | 1 | ▶ | if ( my $set_headers = $self->set ) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 23 | 3 | ▶ | Plack::Util::header_iter($set_headers, sub { | ||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | 3 | my ( $key, $val ) = @_; | |||||||||||
| 25 | 3 | $env->{ $self->build_req_header_key($key) } = $val; | |||||||||||
| 26 | 1 | }); | |||||||||||
| 27 | } | ||||||||||||
| 28 | |||||||||||||
| 29 | 1 | ▶ | delete $env->{ $self->build_req_header_key($_) } for @{$self->unset || []}; | ||||||||||
|
Condition50%1/2
$self->unset || []
MC/DC0%0/1
$self->unset || []
$self->unset
Truth table50%1/2
A
A= $self->unset
| |||||||||||||
| 30 | |||||||||||||
| 31 | 1 | return $self->app->($env); | |||||||||||
| 32 | } | ||||||||||||
| 33 | |||||||||||||
| 34 | 2 | 1; | |||||||||||
| 35 | |||||||||||||
| 36 | __END__ | ||||||||||||