GX/HTTP/Parser/Body.pm

filter: Statementstmt 91.6% 22 / 24 Branchbran 80.0% 8 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 3 / 4 Podpod 100% 2 / 2 totaltotal 87.5% 35 / 40 CC 6 SCAR 15.0
CC
6
Cov
88%
new
6.0
parse
2.0
BEGIN
1.0
CRAP 4.5
« GX/HTTP/Headers.pm ↑ Summary GX/Route/Static.pm »
1 # ----------------------------------------------------------------------------------------------------------------------
2 # GX Framework (c) 2009-2011 Jörg A. Uzarek <uzarek@runlevelnull.de>
3 # File: GX/HTTP/Parser/Body.pm
4 # ----------------------------------------------------------------------------------------------------------------------
5  
6 package GX::HTTP::Parser::Body;
7  
8 15 ▶use GX::Exception;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 # ----------------------------------------------------------------------------------------------------------------------
12 # Class setup
13 # ----------------------------------------------------------------------------------------------------------------------
14  
15 15 ▶use GX::Class::Object;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 15 has 'discard_uploads' => (
18 isa => 'Bool'
19 );
20  
21 15 has 'tmp_dir' => (
22 isa => 'Scalar'
23 );
24  
25 15 build;
26  
27  
28 # ----------------------------------------------------------------------------------------------------------------------
29 # Subclasses
30 # ----------------------------------------------------------------------------------------------------------------------
31  
32 15 my %CONTENT_TYPE_TO_CLASS_MAP = (
33 'application/x-www-form-urlencoded' => 'GX::HTTP::Parser::Body::URLEncoded',
34 'multipart/form-data' => 'GX::HTTP::Parser::Body::MultiPart'
35 );
36  
37 {
38  
39 15 ▶ eval "require $_" or throw $@ for values %CONTENT_TYPE_TO_CLASS_MAP;
Branch: 1 branch
BranchTrueFalseTotal
eval "require $_" or &throw($@) 30 0 30
40  
41 }
42  
43  
44 # ----------------------------------------------------------------------------------------------------------------------
45 # Constructor
46 # ----------------------------------------------------------------------------------------------------------------------
47  
48 354 ▶sub new {
Subroutine new: called CC=6 SCAR=18.0
Pod documented
49  
50 354 my $class = shift;
51 354 ▶ my %args = ( @_ == 1 ) ? ( content_type => $_[0] ) : @_;
Branch: 1 branch
BranchTrueFalseTotal
@_ == 1 ? : 2 352 354
52  
53 354 ▶ if ( $class eq __PACKAGE__ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($class eq __PACKAGE__) 7 347 354
54  
55 7 ▶ if ( defined $args{'content_type'} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $args{"content_type"}) 7 0 7
56  
57 7 my $content_type = lc $args{'content_type'};
58  
59 7 for ( keys %CONTENT_TYPE_TO_CLASS_MAP ) {
60  
61 10 ▶ if ( index( $content_type, $_ ) >= 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if (index($content_type, $_) != -1) 7 3 10
62 7 return $CONTENT_TYPE_TO_CLASS_MAP{$_}->SUPER::new( %args );
63 }
64  
65 }
66  
67 }
68  
69 0 return undef;
70  
71 }
72  
73 347 return $class->SUPER::new( %args );
74  
75 }
76  
77  
78 # ----------------------------------------------------------------------------------------------------------------------
79 # Public methods
80 # ----------------------------------------------------------------------------------------------------------------------
81  
82 0 ▶sub parse {
Subroutine parse: not called CC=1 SCAR=6.9
Pod documented
83  
84 0 return undef;
85  
86 }
87  
88  
89 15 1;
90  
91 __END__
« GX/HTTP/Headers.pm ↑ Summary GX/Route/Static.pm »