| 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
| |||||||||||
| 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
| |||||||||||
| 52 | |||||||||||
| 53 | 354 | ▶ | if ( $class eq __PACKAGE__ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 54 | |||||||||||
| 55 | 7 | ▶ | if ( defined $args{'content_type'} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 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
| |||||||||||
| 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__ | ||||||||||