| 1 | package HTTP::Parser::XS; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 14 | our %EXPORT_TAGS = ( | |||||||||||||||||||||||||||
| 9 | 'all' => [ qw/parse_http_request parse_http_response | ||||||||||||||||||||||||||||
| 10 | HEADERS_NONE HEADERS_AS_HASHREF HEADERS_AS_ARRAYREF/ ], | ||||||||||||||||||||||||||||
| 11 | ); | ||||||||||||||||||||||||||||
| 12 | 14 | our @EXPORT_OK = @{$EXPORT_TAGS{all}}; | |||||||||||||||||||||||||||
| 13 | 14 | our @EXPORT = (); | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # header format for parse_http_response() | ||||||||||||||||||||||||||||
| 16 | 14 | ▶ | use constant { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 14 | 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 | 14 | }; | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 14 | our $VERSION = '0.18'; | |||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 14 | our $BACKEND; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 14 | ▶ | if (not __PACKAGE__->can('parse_http_response')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | 14 | ▶ | $BACKEND = $ENV{PERL_HTTP_PARSER_XS} || ($ENV{PERL_ONLY} ? 'pp' : ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$ENV{'PERL_HTTP_PARSER_XS'} || ($ENV{'PERL_ONLY'} ? 'pp' : '')
MC/DC50%1/2
$ENV{'PERL_HTTP_PARSER_XS'} || ($ENV{'PERL_ONLY'} ? 'pp' : '')
$ENV{'PERL_HTTP_PARSER_XS'}
($ENV{'PERL_ONLY'} ? 'pp' : '')
Truth table66%2/3
A || B
A= $ENV{'PERL_HTTP_PARSER_XS'}B= ($ENV{'PERL_ONLY'} ? 'pp' : '')
| |||||||||||||||||||||||||||||
| 28 | 14 | ▶ | if ($BACKEND !~ /\b pp \b/xms) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | 7 | eval { | |||||||||||||||||||||||||||
| 30 | 7 | require XSLoader; | |||||||||||||||||||||||||||
| 31 | 7 | XSLoader::load(__PACKAGE__, $VERSION); | |||||||||||||||||||||||||||
| 32 | 7 | $BACKEND = 'xs'; | |||||||||||||||||||||||||||
| 33 | }; | ||||||||||||||||||||||||||||
| 34 | 7 | ▶ | die $@ if $@ && $BACKEND =~ /\bxs\b/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$@ and $HTTP::Parser::XS::BACKEND =~ /\bxs\b/
MC/DC0%0/2
$@ and $HTTP::Parser::XS::BACKEND =~ /\bxs\b/
$@
$HTTP::Parser::XS::BACKEND =~ /\bxs\b/
Truth table33%1/3
A and B
A= $@B= $HTTP::Parser::XS::BACKEND =~ /\bxs\b/
| |||||||||||||||||||||||||||||
| 35 | } | ||||||||||||||||||||||||||||
| 36 | 14 | ▶ | if (not __PACKAGE__->can('parse_http_response')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 7 | require HTTP::Parser::XS::PP; | |||||||||||||||||||||||||||
| 38 | 7 | $BACKEND = 'pp'; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 14 | 1; | |||||||||||||||||||||||||||
| 43 | __END__ | ||||||||||||||||||||||||||||