| 1 | |||||||||||
| 2 | package Net::OBEX::Response::Generic; | ||||||||||
| 3 | |||||||||||
| 4 | |||||||||||
| 5 | 8 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 8 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 8 | our $VERSION = '1.001002'; # VERSION | |||||||||
| 9 | |||||||||||
| 10 | 8 | ▶ | use Carp; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | 8 | ▶ | use base 'Class::Data::Accessor'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 12 | 8 | __PACKAGE__->mk_classaccessors( qw( headers_length packet info ) ); | |||||||||
| 13 | |||||||||||
| 14 | |||||||||||
| 15 | 8 | my %Response_meaning_of_code = _make_response_codes(); | |||||||||
| 16 | |||||||||||
| 17 | 8 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||
| 18 | 8 | my $class = shift; | |||||||||
| 19 | 8 | my $packet = shift; | |||||||||
| 20 | |||||||||||
| 21 | 8 | my $self = bless {}, $class; | |||||||||
| 22 | |||||||||||
| 23 | 8 | ▶ | if ( defined $packet ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | $self->packet( $packet ); | |||||||||
| 25 | 0 | $self->info( $self->parse_info( $packet ) ); | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | 8 | return $self; | |||||||||
| 29 | } | ||||||||||
| 30 | |||||||||||
| 31 | 2 | ▶ | sub parse_info { | ||||||||
|
Subroutine
parse_info: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 32 | 2 | my ( $self, $packet ) = @_; | |||||||||
| 33 | 2 | ▶ | $packet = $self->packet | ||||||||
|
Branch: 1 branch
| |||||||||||
| 34 | unless defined $packet; | ||||||||||
| 35 | |||||||||||
| 36 | 2 | my %info; | |||||||||
| 37 | 2 | @info{ qw( response_code packet_length) } | |||||||||
| 38 | = unpack 'a n', $packet; | ||||||||||
| 39 | |||||||||||
| 40 | @info{qw( response_code response_code_meaning ) } = | ||||||||||
| 41 | 2 | $self->code_meaning( $info{response_code} ); | |||||||||
| 42 | |||||||||||
| 43 | 2 | $info{headers_length} = $info{packet_length} - 3; | |||||||||
| 44 | 2 | $self->headers_length( $info{headers_length} ); | |||||||||
| 45 | |||||||||||
| 46 | 2 | return $self->info( \%info ); | |||||||||
| 47 | } | ||||||||||
| 48 | |||||||||||
| 49 | 4 | ▶ | sub code_meaning { | ||||||||
|
Subroutine
code_meaning: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 50 | 4 | my ( $class, $code ) = @_; | |||||||||
| 51 | 4 | return @{ $Response_meaning_of_code{ $code } }; | |||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | 8 | ▶ | sub _make_response_codes { | ||||||||
|
Subroutine
_make_response_codes: called CC=1 SCAR=0.0
| |||||||||||
| 55 | return ( | ||||||||||
| 56 | 8 | "\x90" => [ 100, 'Continue' ], | |||||||||
| 57 | "\xA0" => [ 200, 'OK, Success' ], | ||||||||||
| 58 | "\xA1" => [ 201, 'Created' ], | ||||||||||
| 59 | "\xA2" => [ 202, 'Accepted' ], | ||||||||||
| 60 | "\xA3" => [ 203, 'Non-Authoritative Information' ], | ||||||||||
| 61 | "\xA4" => [ 204, 'No Content' ], | ||||||||||
| 62 | "\xA5" => [ 205, 'Reset Content' ], | ||||||||||
| 63 | "\xA6" => [ 206, 'Partial Content' ], | ||||||||||
| 64 | "\xB0" => [ 300, 'Multiple Choices' ], | ||||||||||
| 65 | "\xB1" => [ 301, 'Moved Permanently' ], | ||||||||||
| 66 | "\xB2" => [ 302, 'Moved temporarily' ], | ||||||||||
| 67 | "\xB3" => [ 303, 'See Other' ], | ||||||||||
| 68 | "\xB4" => [ 304, 'Not modified' ], | ||||||||||
| 69 | "\xB5" => [ 305, 'Use Proxy' ], | ||||||||||
| 70 | "\xC0" => [ 400, q|Bad Request - server couldn't understand request| ], | ||||||||||
| 71 | "\xC1" => [ 401, 'Unauthorized' ], | ||||||||||
| 72 | "\xC2" => [ 402, 'Payment required' ], | ||||||||||
| 73 | "\xC3" => [ 403, 'Forbidden - operation is understood but refused' ], | ||||||||||
| 74 | "\xC4" => [ 404, 'Not Found' ], | ||||||||||
| 75 | "\xC5" => [ 405, 'Method not allowed' ], | ||||||||||
| 76 | "\xC6" => [ 406, 'Not Acceptable' ], | ||||||||||
| 77 | "\xC7" => [ 407, 'Proxy Authentication required' ], | ||||||||||
| 78 | "\xC8" => [ 408, 'Request Time Out' ], | ||||||||||
| 79 | "\xC9" => [ 409, 'Conflict' ], | ||||||||||
| 80 | "\xCA" => [ 410, 'Gone' ], | ||||||||||
| 81 | "\xCB" => [ 411, 'Length Required' ], | ||||||||||
| 82 | "\xCC" => [ 412, 'Precondition failed' ], | ||||||||||
| 83 | "\xCD" => [ 413, 'Requested entity too large' ], | ||||||||||
| 84 | "\xCE" => [ 414, 'Request URL too large' ], | ||||||||||
| 85 | "\xCF" => [ 415, 'Unsupported media type' ], | ||||||||||
| 86 | "\xD0" => [ 500, 'Internal Server Error' ], | ||||||||||
| 87 | "\xD1" => [ 501, 'Not Implemented' ], | ||||||||||
| 88 | "\xD2" => [ 502, 'Bad Gateway' ], | ||||||||||
| 89 | "\xD3" => [ 503, 'Service Unavailable' ], | ||||||||||
| 90 | "\xD4" => [ 504, 'Gateway Timeout' ], | ||||||||||
| 91 | "\xD5" => [ 505, 'HTTP version not supported' ], | ||||||||||
| 92 | "\xE0" => [ undef, 'Database Full' ], | ||||||||||
| 93 | "\xE1" => [ undef, 'Database Locked' ], | ||||||||||
| 94 | ); | ||||||||||
| 95 | } | ||||||||||
| 96 | |||||||||||
| 97 | 8 | 1; | |||||||||
| 98 | |||||||||||
| 99 | __END__ | ||||||||||