line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package POE::Filter::SimpleHTTP::Error; |
2
|
|
|
|
|
|
|
our $VERSION = '0.091710'; |
3
|
|
|
|
|
|
|
|
4
|
2
|
|
|
2
|
|
4095
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Moose::Util::TypeConstraints; |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant |
8
|
|
|
|
|
|
|
{ |
9
|
|
|
|
|
|
|
UNPARSABLE_PREAMBLE => 0, |
10
|
|
|
|
|
|
|
TRAILING_DATA => 1, |
11
|
|
|
|
|
|
|
CHUNKED_ISNT_LAST => 2, |
12
|
|
|
|
|
|
|
INFLATE_FAILED_INIT => 3, |
13
|
|
|
|
|
|
|
INFLATE_FAILED_INFLATE => 4, |
14
|
|
|
|
|
|
|
UNCOMPRESS_FAILED => 5, |
15
|
|
|
|
|
|
|
GUNZIP_FAILED => 6, |
16
|
|
|
|
|
|
|
UNKNOWN_TRANSFER_ENCODING => 7, |
17
|
|
|
|
|
|
|
}; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
extends('Exporter'); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our @EXPORT = qw/ UNPARSABLE_PREAMBLE TRAILING_DATA CHUNKED_ISNT_LAST |
22
|
|
|
|
|
|
|
INFLATE_FAILED_INIT INFLATE_FAILED_INFLATE UNCOMPRESS_FAILED |
23
|
|
|
|
|
|
|
GUNZIP_FAILED UNKNOWN_TRANSFER_ENCODING /; |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
subtype 'ErrorType' |
26
|
|
|
|
|
|
|
=> as 'Int' |
27
|
|
|
|
|
|
|
=> where { -1 < $_ && $_ < 8 } |
28
|
|
|
|
|
|
|
=> message { 'Invalid ErrorType' }; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'error' => |
31
|
|
|
|
|
|
|
( |
32
|
|
|
|
|
|
|
is => 'rw', |
33
|
|
|
|
|
|
|
isa => 'ErrorType' |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has 'context' => |
37
|
|
|
|
|
|
|
( |
38
|
|
|
|
|
|
|
is => 'rw', |
39
|
|
|
|
|
|
|
isa => 'Str', |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=pod |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 NAME |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
POE::Filter::SimpleHTTP::Error - An error object for SimpleHTTP |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head1 VERSION |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
version 0.091710 |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head1 SYNOPSIS |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
use 5.010; |
56
|
|
|
|
|
|
|
use POE::Filter::SimpleHTTP; |
57
|
|
|
|
|
|
|
use POE::Filter::SimpleHTTP::Error; #exports constants by default |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
my $filter = POE::Filter::SimpleHTTP->new(); |
60
|
|
|
|
|
|
|
$filter->get_one_start([qw/junk data goes here/]); |
61
|
|
|
|
|
|
|
my $ret = $filter->get_one()->[0]; |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
if($ret->isa('POE::Filter::SimpleHTTP::Error')) |
64
|
|
|
|
|
|
|
{ |
65
|
|
|
|
|
|
|
say $ret->error(); # 0 (aka. UNPARSABLE_PREAMBLE); |
66
|
|
|
|
|
|
|
say $ret->context(); # junkdatagoeshere |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 DESCRIPTION |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
This module provides the error class and exported constants for use downstream |
72
|
|
|
|
|
|
|
from the filter to determine what went wrong. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head1 PUBLIC ACCESSORS |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=over 4 |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item error() |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
error() contains the actual error code from the filter that corresponds with |
81
|
|
|
|
|
|
|
the exported constants. Suitable for use in numeric comparisons (ie. ==) |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=item context() |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
If the error has any context associated with it, it will be stored here. Note |
86
|
|
|
|
|
|
|
that some decompression routines do not provide a status message, just return |
87
|
|
|
|
|
|
|
undef, and so there is no context returned. |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=back |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 EXPORTED CONSTANTS |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=over 4 |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=item UNPARSABLE_PREAMBLE |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
The data provided doesn't parse for some reason as either a Response or |
98
|
|
|
|
|
|
|
Request. Context provided. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=item TRAILING_DATA |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
The message contains trailing data that isn't allowed by the RFC. |
103
|
|
|
|
|
|
|
Context provided. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item CHUNKED_ISNT_LAST |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
chunked isn't last in the transfer encodings. This isn't allowed by the RFC. |
108
|
|
|
|
|
|
|
Context provided. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=item INFLATE_FAILED_INIT |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
Compress::Zlib::inflateInit failed. Context provided. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item INFLATE_FAILED_INFLATE |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
inflate() failed. Context provided. |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item UNCOMPRESS_FAILED |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
uncompress() failed. No context. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=item GUNZIP_FAILED |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
memGunzip() failed. No context. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item UNKNOWN_TRANSFER_ENCODING |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
A transfer encoding was not recognized. Context provided. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=back |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHOR |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Copyright 2009 Nicholas Perez. |
135
|
|
|
|
|
|
|
Licensed and distributed under the GPL. |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=cut |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable(); |
140
|
|
|
|
|
|
|
no Moose; |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
1; |