line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTTP::Parser::XS; |
2
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
233722
|
use strict; |
|
12
|
|
|
|
|
23
|
|
|
12
|
|
|
|
|
570
|
|
4
|
12
|
|
|
12
|
|
60
|
use warnings; |
|
12
|
|
|
|
|
17
|
|
|
12
|
|
|
|
|
379
|
|
5
|
|
|
|
|
|
|
|
6
|
12
|
|
|
12
|
|
60
|
use base qw(Exporter); |
|
12
|
|
|
|
|
24
|
|
|
12
|
|
|
|
|
2123
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our %EXPORT_TAGS = ( |
9
|
|
|
|
|
|
|
'all' => [ qw/parse_http_request parse_http_response |
10
|
|
|
|
|
|
|
HEADERS_NONE HEADERS_AS_HASHREF HEADERS_AS_ARRAYREF/ ], |
11
|
|
|
|
|
|
|
); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = @{$EXPORT_TAGS{all}}; |
13
|
|
|
|
|
|
|
our @EXPORT = (); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# header format for parse_http_response() |
16
|
|
|
|
|
|
|
use constant { |
17
|
12
|
|
|
|
|
3175
|
HEADERS_NONE => 0, # don't parse headers. It's fastest. if you want only special headers, also fastest. |
18
|
|
|
|
|
|
|
HEADERS_AS_HASHREF => 1, # HTTP::Headers compatible HashRef, { header_name => "header_value" or ["val1", "val2"] } |
19
|
|
|
|
|
|
|
HEADERS_AS_ARRAYREF =>2, # Ordered ArrayRef : [ name, value, name2, value2 ... ] |
20
|
12
|
|
|
12
|
|
62
|
}; |
|
12
|
|
|
|
|
18
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
our $BACKEND; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
if (not __PACKAGE__->can('parse_http_response')) { |
27
|
|
|
|
|
|
|
$BACKEND = $ENV{PERL_HTTP_PARSER_XS} || ($ENV{PERL_ONLY} ? 'pp' : ''); |
28
|
|
|
|
|
|
|
if ($BACKEND !~ /\b pp \b/xms) { |
29
|
|
|
|
|
|
|
eval { |
30
|
|
|
|
|
|
|
require XSLoader; |
31
|
|
|
|
|
|
|
XSLoader::load(__PACKAGE__, $VERSION); |
32
|
|
|
|
|
|
|
$BACKEND = 'xs'; |
33
|
|
|
|
|
|
|
}; |
34
|
|
|
|
|
|
|
die $@ if $@ && $BACKEND =~ /\bxs\b/; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
if (not __PACKAGE__->can('parse_http_response')) { |
37
|
|
|
|
|
|
|
require HTTP::Parser::XS::PP; |
38
|
|
|
|
|
|
|
$BACKEND = 'pp'; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
1; |
43
|
|
|
|
|
|
|
__END__ |