WARC/Record/Replay/HTTP/Request.pm

filter: Statementstmt 100% 45 / 45 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 8 / 8 Podpod n/a totaltotal 100% 61 / 61 CC 6 SCAR 8.0
CC
6
Cov
100%
_load_record
4.0
__ANON__
2.0
BEGIN
2.0
CRAP 2.2
« WARC/Record.pm ↑ Summary WARC/Record/Payload.pm »
1 package WARC::Record::Replay::HTTP::Request; # -*- CPerl -*-
2  
3 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 4 require HTTP::Request;
7 4 require WARC::Record::Replay::HTTP::Message;
8 4 our @ISA = qw(WARC::Record::Replay::HTTP::Message HTTP::Request);
9  
10 4 ▶use WARC; *WARC::Record::Replay::HTTP::Request::VERSION = \$WARC::VERSION;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 4 require WARC::Record::Replay;
13  
14 WARC::Record::Replay::register
15 131 ▶ { $_->field('Content-Type') =~ m|^application/http; msgtype=request| }
Subroutine __ANON__: called CC=1 SCAR=0.0
16 4 \&_load_record;
17 WARC::Record::Replay::register
18 131 ▶ { $_->field('Content-Type') =~ m|^application/http| && $_->type eq 'request' }
Subroutine __ANON__: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
$_->field("Content-Type") =~ m[^application/http] and $_->type eq "request" 128 3 131
19 4 \&_load_record;
20  
21 BEGIN {
22 4 ▶ use WARC::Record::Replay::HTTP;
Subroutine BEGIN: called CC=1 SCAR=0.0
23 $WARC::Record::Replay::HTTP::Request::{$_} =
24 $WARC::Record::Replay::HTTP::{$_}
25 4 ▶ for WARC::Record::Replay::HTTP::HTTP_PARSE_REs;
Subroutine BEGIN: called CC=2 SCAR=6.9
26 }
27  
28  
29 sub _load_record {
30 60 ▶ my $record = shift;
Subroutine _load_record: called CC=4 SCAR=13.9
31  
32 60 my $handle = $record->open_continued;
33  
34 60 ▶ if ($record->field('Content-Length')
Branch: 1 branch
BranchTrueFalseTotal
if ($record->field("Content-Length") < $WARC::Record::Replay::HTTP::Content_Deferred_Loading_Threshold) 46 14 60
35 < $WARC::Record::Replay::HTTP::Content_Deferred_Loading_Threshold) {
36 # The entire WARC block is smaller than the deferred loading threshold;
37 # this is an easy special case.
38 46 my $block;
39 {
40 46 local $/ = undef; # slurp
41 46 $block = <$handle>;
42 }
43 46 my $request = HTTP::Request->parse($block);
44 46 ▶ return $request->protocol =~ $HTTP__Version ? $request : undef;
Branch: 1 branch
BranchTrueFalseTotal
$request->protocol =~ /$WARC::Record::Replay::HTTP::HTTP__Version/ ? : 42 4 46
45 }
46  
47 14 my $method; my $uri; my $http_version;
48 {
49 14 local $/ = "\012";
50 14 my $line = <$handle>;
51 14 $line =~ s/[[:space:]]+$//; # trim trailing CR if present
52 14 ▶ return undef unless $line =~ $HTTP__Request_Line;
Branch: 1 branch
BranchTrueFalseTotal
unless $line =~ /$WARC::Record::Replay::HTTP::HTTP__Request_Line/ 2 12 14
53 # $1 -- HTTP Method $2 -- Request-URI $3 -- HTTP-Version
54 12 $method = $1; $uri = $2; $http_version = $3;
55 }
56  
57 12 my $ob = HTTP::Request->new($method, $uri);
58 12 $ob->protocol($http_version);
59  
60 12 WARC::Record::Replay::HTTP::Message::_load_record($ob, $record, $handle);
61 }
62  
63 4 1;
64 __END__
« WARC/Record.pm ↑ Summary WARC/Record/Payload.pm »