blib/lib/HTTP/Parser/XS.pm

filter: Statementstmt 100% 30 / 30 Branchbran 80.0% 8 / 10 Conditioncond 50.0% 3 / 6 MC/DCmcdc 25.0% 1 / 4 Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 85.1% 46 / 54 CC 1 SCAR 0.0
CC
1
Cov
89%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« picohttpparser/picohttpparser.c ↑ Summary XS.xs »
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
BranchTrueFalseTotal
unless (__PACKAGE__->can("parse_http_response")) 14 0 14
27 14 ▶ $BACKEND = $ENV{PERL_HTTP_PARSER_XS} || ($ENV{PERL_ONLY} ? 'pp' : '');
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERL_ONLY'} ? : 7 7 14
Condition66%2/3
$ENV{'PERL_HTTP_PARSER_XS'} || ($ENV{'PERL_ONLY'} ? 'pp' : '')
l!l&&r!l&&!r
077
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' : '')
ABresult
1X1
011
000
28 14 ▶ if ($BACKEND !~ /\b pp \b/xms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($HTTP::Parser::XS::BACKEND =~ /\b pp \b/msx) 7 7 14
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
BranchTrueFalseTotal
if $@ and $HTTP::Parser::XS::BACKEND =~ /\bxs\b/ 0 7 7
Condition33%1/3
$@ and $HTTP::Parser::XS::BACKEND =~ /\bxs\b/
!ll&&!rl&&r
700
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/
ABresult
0X0
100
111
35 }
36 14 ▶ if (not __PACKAGE__->can('parse_http_response')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (__PACKAGE__->can("parse_http_response")) 7 7 14
37 7 require HTTP::Parser::XS::PP;
38 7 $BACKEND = 'pp';
39 }
40 }
41  
42 14 1;
43 __END__
« picohttpparser/picohttpparser.c ↑ Summary XS.xs »