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 12 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 12 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 12 ▶use base qw(Exporter);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 12 our %EXPORT_TAGS = (
9 'all' => [ qw/parse_http_request parse_http_response
10 HEADERS_NONE HEADERS_AS_HASHREF HEADERS_AS_ARRAYREF/ ],
11 );
12 12 our @EXPORT_OK = @{$EXPORT_TAGS{all}};
13 12 our @EXPORT = ();
14  
15 # header format for parse_http_response()
16 12 ▶use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
17 12 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 };
21  
22 12 our $VERSION = '0.17';
23  
24 12 our $BACKEND;
25  
26 12 ▶if (not __PACKAGE__->can('parse_http_response')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (__PACKAGE__->can("parse_http_response")) 12 0 12
27 12 ▶ $BACKEND = $ENV{PERL_HTTP_PARSER_XS} || ($ENV{PERL_ONLY} ? 'pp' : '');
Branch: 1 branch
BranchTrueFalseTotal
$ENV{'PERL_ONLY'} ? : 6 6 12
Condition66%2/3
$ENV{'PERL_HTTP_PARSER_XS'} || ($ENV{'PERL_ONLY'} ? 'pp' : '')
l!l&&r!l&&!r
066
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 12 ▶ if ($BACKEND !~ /\b pp \b/xms) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($HTTP::Parser::XS::BACKEND =~ /\b pp \b/msx) 6 6 12
29 6 eval {
30 6 require XSLoader;
31 6 XSLoader::load(__PACKAGE__, $VERSION);
32 6 $BACKEND = 'xs';
33 };
34 6 ▶ die $@ if $@ && $BACKEND =~ /\bxs\b/;
Branch: 1 branch
BranchTrueFalseTotal
if $@ and $HTTP::Parser::XS::BACKEND =~ /\bxs\b/ 0 6 6
Condition33%1/3
$@ and $HTTP::Parser::XS::BACKEND =~ /\bxs\b/
!ll&&!rl&&r
600
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 12 ▶ if (not __PACKAGE__->can('parse_http_response')) {
Branch: 1 branch
BranchTrueFalseTotal
unless (__PACKAGE__->can("parse_http_response")) 6 6 12
37 6 require HTTP::Parser::XS::PP;
38 6 $BACKEND = 'pp';
39 }
40 }
41  
42 12 1;
43 __END__
« picohttpparser/picohttpparser.c ↑ Summary XS.xs »