| 1 | package Archive::Har; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use English qw(-no_match_vars); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Archive::Har::Creator(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use Archive::Har::Browser(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 10 | ▶ | use Archive::Har::Page(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 10 | ▶ | use Archive::Har::Entry(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 10 | ▶ | use XML::LibXML(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 10 | ▶ | use IO::Compress::Gzip(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 10 | ▶ | use IO::Uncompress::Gunzip(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 10 | ▶ | use JSON(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 10 | ▶ | use overload '""' => 'string'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 10 | our $VERSION = '0.21'; | |||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||
| 18 | 10 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 19 | 10 | my ( $class, $params ) = @_; | |||||||||||||||||||||||||||
| 20 | 10 | my $self = {}; | |||||||||||||||||||||||||||
| 21 | 10 | bless $self, $class; | |||||||||||||||||||||||||||
| 22 | 10 | $self->_init(); | |||||||||||||||||||||||||||
| 23 | 10 | return $self; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 26 | ▶ | sub _init { | ||||||||||||||||||||||||||
|
Subroutine
_init: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 27 | 26 | my ($self) = @_; | |||||||||||||||||||||||||||
| 28 | 26 | foreach my $key ( keys %{$self} ) { | |||||||||||||||||||||||||||
| 29 | 16 | delete $self->{$key}; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | 26 | $self->{log} = {}; | |||||||||||||||||||||||||||
| 32 | 26 | return; | |||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 4 | ▶ | sub gzip { | ||||||||||||||||||||||||||
|
Subroutine
gzip: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 36 | 4 | my ( $self, $gzipped ) = @_; | |||||||||||||||||||||||||||
| 37 | 4 | my $uncompressed = $self->string(); | |||||||||||||||||||||||||||
| 38 | 4 | my $old; | |||||||||||||||||||||||||||
| 39 | 4 | ▶ | IO::Compress::Gzip::gzip( \$uncompressed, \$old, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | -Level => IO::Compress::Gzip::Z_BEST_COMPRESSION() ) | ||||||||||||||||||||||||||||
| 41 | or | ||||||||||||||||||||||||||||
| 42 | Carp::croak("Failed to gzip HAR archive:$IO::Compress::Gzip::GzipError"); | ||||||||||||||||||||||||||||
| 43 | 3 | ▶ | if ( defined $gzipped ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 2 | my $string; | |||||||||||||||||||||||||||
| 45 | 2 | ▶ | IO::Uncompress::Gunzip::gunzip( \$gzipped, \$string ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 46 | or Carp::croak('Failed to gunzip HAR archive'); | ||||||||||||||||||||||||||||
| 47 | 1 | $self->string($string); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | 2 | return $old; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 33 | ▶ | sub hashref { | ||||||||||||||||||||||||||
|
Subroutine
hashref: called CC=5 SCAR=16.1
Pod
documented
| |||||||||||||||||||||||||||||
| 53 | 33 | my ( $self, $ref ) = @_; | |||||||||||||||||||||||||||
| 54 | 33 | my $old = JSON->new()->utf8()->decode( $self->string() ); | |||||||||||||||||||||||||||
| 55 | 33 | ▶ | if ( ( @_ > 1 ) && ( defined $ref ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ > 1 and defined $ref
MC/DC50%1/2
@_ > 1 and defined $ref
@_ > 1
defined $ref
Truth table66%2/3
A and B
A= @_ > 1B= defined $ref
| |||||||||||||||||||||||||||||
| 56 | 14 | $self->_init(); | |||||||||||||||||||||||||||
| 57 | 14 | $self->version( $ref->{log}->{version} ); | |||||||||||||||||||||||||||
| 58 | 14 | $self->creator( Archive::Har::Creator->new( $ref->{log}->{creator} ) ); | |||||||||||||||||||||||||||
| 59 | 14 | ▶ | if ( defined $ref->{log}->{browser} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | $self->browser( | ||||||||||||||||||||||||||||
| 61 | 7 | Archive::Har::Browser->new( $ref->{log}->{browser} ) ); | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | 14 | ▶ | if ( defined $ref->{log}->{pages} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 64 | 11 | $self->pages( $ref->{log}->{pages} ); | |||||||||||||||||||||||||||
| 65 | } | ||||||||||||||||||||||||||||
| 66 | 14 | $self->entries( $ref->{log}->{entries} ); | |||||||||||||||||||||||||||
| 67 | 14 | $self->comment( $ref->{log}->{comment} ); | |||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | 33 | return $old; | |||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 85 | ▶ | sub string { | ||||||||||||||||||||||||||
|
Subroutine
string: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 73 | 85 | my ( $self, $string ) = @_; | |||||||||||||||||||||||||||
| 74 | 85 | ▶ | if ( defined $string ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 75 | 14 | my $utf8_regex = qr/\xef\xbb\xbf/smx; | |||||||||||||||||||||||||||
| 76 | 14 | my $utf16_regex = qr/(?:\xfe\xff|\xff\xfe)/smx; | |||||||||||||||||||||||||||
| 77 | 14 | my $utf32_regex = qr/(?:\x00\x00\xfe\xff|\xff\xfe\x00\x00)/smx; | |||||||||||||||||||||||||||
| 78 | 14 | $string =~ s/^(?:$utf8_regex|$utf16_regex|$utf32_regex)//smxg; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | 85 | my $json = JSON->new(); | |||||||||||||||||||||||||||
| 81 | 85 | $json = $json->utf8(); | |||||||||||||||||||||||||||
| 82 | 85 | $json = $json->allow_blessed(1); | |||||||||||||||||||||||||||
| 83 | 85 | $json = $json->convert_blessed(1); | |||||||||||||||||||||||||||
| 84 | 85 | $json = $json->pretty(); | |||||||||||||||||||||||||||
| 85 | 85 | $json = $json->canonical(1); | |||||||||||||||||||||||||||
| 86 | 85 | my $old = $json->encode($self); | |||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 85 | ▶ | if ( ( @_ > 1 ) && ( defined $string ) ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
@_ > 1 and defined $string
MC/DC100%2/2
@_ > 1 and defined $string
@_ > 1
defined $string
Truth table100%3/3
A and B
A= @_ > 1B= defined $string
| |||||||||||||||||||||||||||||
| 89 | 14 | my $ref = JSON->new()->utf8()->decode($string); | |||||||||||||||||||||||||||
| 90 | 14 | $self->hashref($ref); | |||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||
| 92 | 85 | return $old; | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | 2 | ▶ | sub _xml_creator { | ||||||||||||||||||||||||||
|
Subroutine
_xml_creator: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 96 | 2 | my ( $self, $ie_log ) = @_; | |||||||||||||||||||||||||||
| 97 | 2 | foreach my $ie_creator ( $ie_log->getChildrenByTagName('creator') ) { | |||||||||||||||||||||||||||
| 98 | 2 | $self->creator( Archive::Har::Creator->new() ); | |||||||||||||||||||||||||||
| 99 | 2 | foreach my $ie_name ( $ie_creator->getChildrenByTagName('name') ) { | |||||||||||||||||||||||||||
| 100 | 2 | $self->creator()->name( $ie_name->findvalue('text()') ); | |||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||
| 102 | 2 | foreach my $ie_value ( $ie_creator->getChildrenByTagName('version') ) { | |||||||||||||||||||||||||||
| 103 | 2 | $self->creator()->version( $ie_value->findvalue('text()') ); | |||||||||||||||||||||||||||
| 104 | } | ||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | 2 | return; | |||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | 2 | ▶ | sub _xml_browser { | ||||||||||||||||||||||||||
|
Subroutine
_xml_browser: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||
| 110 | 2 | my ( $self, $ie_log ) = @_; | |||||||||||||||||||||||||||
| 111 | 2 | foreach my $ie_browser ( $ie_log->getChildrenByTagName('browser') ) { | |||||||||||||||||||||||||||
| 112 | 2 | $self->browser( Archive::Har::Creator->new() ); | |||||||||||||||||||||||||||
| 113 | 2 | foreach my $ie_name ( $ie_browser->getChildrenByTagName('name') ) { | |||||||||||||||||||||||||||
| 114 | 2 | $self->browser()->name( $ie_name->findvalue('text()') ); | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | 2 | foreach my $ie_value ( $ie_browser->getChildrenByTagName('version') ) { | |||||||||||||||||||||||||||
| 117 | 2 | $self->browser()->version( $ie_value->findvalue('text()') ); | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||
| 120 | 2 | return; | |||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||
| 123 | 2 | ▶ | sub _xml_pages { | ||||||||||||||||||||||||||
|
Subroutine
_xml_pages: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||
| 124 | 2 | my ( $self, $ie_log ) = @_; | |||||||||||||||||||||||||||
| 125 | 2 | foreach my $ie_pages ( $ie_log->getChildrenByTagName('pages') ) { | |||||||||||||||||||||||||||
| 126 | 2 | my @pages; | |||||||||||||||||||||||||||
| 127 | 2 | foreach my $ie_page ( $ie_pages->getChildrenByTagName('page') ) { | |||||||||||||||||||||||||||
| 128 | 2 | my $page = Archive::Har::Page->new(); | |||||||||||||||||||||||||||
| 129 | 2 | foreach my $ie_id ( $ie_page->getChildrenByTagName('id') ) { | |||||||||||||||||||||||||||
| 130 | 2 | $page->id( $ie_id->findvalue('text()') ); | |||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | 2 | foreach my $ie_title ( $ie_page->getChildrenByTagName('title') ) { | |||||||||||||||||||||||||||
| 133 | 2 | $page->title( $ie_title->findvalue('text()') ); | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | 2 | foreach my $ie_started ( | |||||||||||||||||||||||||||
| 136 | $ie_page->getChildrenByTagName('startedDateTime') ) | ||||||||||||||||||||||||||||
| 137 | { | ||||||||||||||||||||||||||||
| 138 | 2 | $page->started_date_time( $ie_started->findvalue('text()') ); | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | 2 | my $page_timings = Archive::Har::Page::PageTimings->new(); | |||||||||||||||||||||||||||
| 141 | 2 | foreach | |||||||||||||||||||||||||||
| 142 | my $ie_timings ( $ie_page->getChildrenByTagName('pageTimings') ) | ||||||||||||||||||||||||||||
| 143 | { | ||||||||||||||||||||||||||||
| 144 | 2 | foreach my $ie_content ( | |||||||||||||||||||||||||||
| 145 | $ie_timings->getChildrenByTagName('onContentLoad') ) | ||||||||||||||||||||||||||||
| 146 | { | ||||||||||||||||||||||||||||
| 147 | 2 | $page_timings->on_content_load( | |||||||||||||||||||||||||||
| 148 | $ie_content->findvalue('text()') ); | ||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||
| 150 | 2 | foreach | |||||||||||||||||||||||||||
| 151 | my $ie_load ( $ie_timings->getChildrenByTagName('onLoad') ) | ||||||||||||||||||||||||||||
| 152 | { | ||||||||||||||||||||||||||||
| 153 | 2 | $page_timings->on_load( $ie_load->findvalue('text()') ); | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | 2 | $page->page_timings($page_timings); | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | 2 | push @pages, $page; | |||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||
| 159 | 2 | $self->pages( \@pages ); | |||||||||||||||||||||||||||
| 160 | } | ||||||||||||||||||||||||||||
| 161 | 2 | return; | |||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 10 | ▶ | sub _xml_cookies { | ||||||||||||||||||||||||||
|
Subroutine
_xml_cookies: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 165 | 10 | my ( $self, $ie_object, $object ) = @_; | |||||||||||||||||||||||||||
| 166 | 10 | foreach my $ie_cookies ( $ie_object->getChildrenByTagName('cookies') ) { | |||||||||||||||||||||||||||
| 167 | 10 | my @cookies; | |||||||||||||||||||||||||||
| 168 | 10 | foreach my $ie_cookie ( $ie_cookies->getChildrenByTagName('cookie') ) { | |||||||||||||||||||||||||||
| 169 | 1 | my $cookie = Archive::Har::Entry::Cookie->new(); | |||||||||||||||||||||||||||
| 170 | 1 | foreach my $ie_name ( $ie_cookie->getChildrenByTagName('name') ) { | |||||||||||||||||||||||||||
| 171 | 1 | $cookie->name( $ie_name->findvalue('text()') ); | |||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||
| 173 | 1 | foreach my $ie_value ( $ie_cookie->getChildrenByTagName('value') ) { | |||||||||||||||||||||||||||
| 174 | 1 | $cookie->value( $ie_value->findvalue('text()') ); | |||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||
| 176 | 1 | push @cookies, $cookie; | |||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||
| 178 | 10 | $object->cookies( \@cookies ); | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | 10 | return; | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 10 | ▶ | sub _xml_headers { | ||||||||||||||||||||||||||
|
Subroutine
_xml_headers: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||
| 184 | 10 | my ( $self, $ie_object, $object ) = @_; | |||||||||||||||||||||||||||
| 185 | 10 | foreach my $ie_headers ( $ie_object->getChildrenByTagName('headers') ) { | |||||||||||||||||||||||||||
| 186 | 10 | my @headers; | |||||||||||||||||||||||||||
| 187 | 10 | foreach my $ie_header ( $ie_headers->getChildrenByTagName('header') ) { | |||||||||||||||||||||||||||
| 188 | 62 | my $header = Archive::Har::Entry::Header->new(); | |||||||||||||||||||||||||||
| 189 | 62 | foreach my $ie_name ( $ie_header->getChildrenByTagName('name') ) { | |||||||||||||||||||||||||||
| 190 | 62 | $header->name( $ie_name->findvalue('text()') ); | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | 62 | foreach my $ie_value ( $ie_header->getChildrenByTagName('value') ) { | |||||||||||||||||||||||||||
| 193 | 62 | $header->value( $ie_value->findvalue('text()') ); | |||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||
| 195 | 62 | push @headers, $header; | |||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||
| 197 | 10 | $object->headers( \@headers ); | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | 10 | return; | |||||||||||||||||||||||||||
| 200 | } | ||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||
| 202 | 5 | ▶ | sub _xml_request { | ||||||||||||||||||||||||||
|
Subroutine
_xml_request: called CC=14 SCAR=26.4
| |||||||||||||||||||||||||||||
| 203 | 5 | my ( $self, $ie_entry, $entry ) = @_; | |||||||||||||||||||||||||||
| 204 | 5 | foreach my $ie_request ( $ie_entry->getChildrenByTagName('request') ) { | |||||||||||||||||||||||||||
| 205 | 5 | my $request = $entry->request(); | |||||||||||||||||||||||||||
| 206 | 5 | foreach my $ie_method ( $ie_request->getChildrenByTagName('method') ) { | |||||||||||||||||||||||||||
| 207 | 5 | $request->method( $ie_method->findvalue('text()') ); | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | 5 | foreach my $ie_url ( $ie_request->getChildrenByTagName('url') ) { | |||||||||||||||||||||||||||
| 210 | 5 | $request->url( $ie_url->findvalue('text()') ); | |||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||
| 212 | 5 | foreach | |||||||||||||||||||||||||||
| 213 | my $ie_version ( $ie_request->getChildrenByTagName('httpVersion') ) | ||||||||||||||||||||||||||||
| 214 | { | ||||||||||||||||||||||||||||
| 215 | 5 | $request->http_version( $ie_version->findvalue('text()') ); | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | 5 | $self->_xml_cookies( $ie_request, $request ); | |||||||||||||||||||||||||||
| 218 | 5 | $self->_xml_headers( $ie_request, $request ); | |||||||||||||||||||||||||||
| 219 | 5 | foreach my $ie_query_string ( | |||||||||||||||||||||||||||
| 220 | $ie_request->getChildrenByTagName('queryString') ) | ||||||||||||||||||||||||||||
| 221 | { | ||||||||||||||||||||||||||||
| 222 | 5 | my @query_strings; | |||||||||||||||||||||||||||
| 223 | 5 | foreach | |||||||||||||||||||||||||||
| 224 | my $ie_param ( $ie_query_string->getChildrenByTagName('param') ) | ||||||||||||||||||||||||||||
| 225 | { | ||||||||||||||||||||||||||||
| 226 | 10 | my $query_string = | |||||||||||||||||||||||||||
| 227 | Archive::Har::Entry::Request::QueryString->new(); | ||||||||||||||||||||||||||||
| 228 | 10 | foreach my $ie_name ( $ie_param->getChildrenByTagName('name') ) | |||||||||||||||||||||||||||
| 229 | { | ||||||||||||||||||||||||||||
| 230 | 10 | $query_string->name( $ie_name->findvalue('text()') ); | |||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||
| 232 | 10 | foreach | |||||||||||||||||||||||||||
| 233 | my $ie_value ( $ie_param->getChildrenByTagName('value') ) | ||||||||||||||||||||||||||||
| 234 | { | ||||||||||||||||||||||||||||
| 235 | 10 | $query_string->value( $ie_value->findvalue('text()') ); | |||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||
| 237 | 10 | push @query_strings, $query_string; | |||||||||||||||||||||||||||
| 238 | } | ||||||||||||||||||||||||||||
| 239 | 5 | $request->query_string( \@query_strings ); | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | 5 | foreach | |||||||||||||||||||||||||||
| 242 | my $ie_post_data ( $ie_request->getChildrenByTagName('postData') ) | ||||||||||||||||||||||||||||
| 243 | { | ||||||||||||||||||||||||||||
| 244 | 1 | my $post_data = Archive::Har::Entry::Request::PostData->new(); | |||||||||||||||||||||||||||
| 245 | 1 | foreach my $ie_mime_type ( | |||||||||||||||||||||||||||
| 246 | $ie_post_data->getChildrenByTagName('mimeType') ) | ||||||||||||||||||||||||||||
| 247 | { | ||||||||||||||||||||||||||||
| 248 | 1 | $post_data->mime_type( $ie_mime_type->findvalue('text()') ); | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | 1 | foreach my $ie_text ( $ie_post_data->getChildrenByTagName('text') ) | |||||||||||||||||||||||||||
| 251 | { | ||||||||||||||||||||||||||||
| 252 | 1 | $post_data->text( $ie_text->findvalue('text()') ); | |||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||
| 254 | 1 | $request->post_data($post_data); | |||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||
| 256 | 5 | foreach my $ie_headers_size ( | |||||||||||||||||||||||||||
| 257 | $ie_request->getChildrenByTagName('headersSize') ) | ||||||||||||||||||||||||||||
| 258 | { | ||||||||||||||||||||||||||||
| 259 | 5 | $request->headers_size( $ie_headers_size->findvalue('text()') ); | |||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||
| 261 | 5 | foreach | |||||||||||||||||||||||||||
| 262 | my $ie_body_size ( $ie_request->getChildrenByTagName('bodySize') ) | ||||||||||||||||||||||||||||
| 263 | { | ||||||||||||||||||||||||||||
| 264 | 5 | $request->body_size( $ie_body_size->findvalue('text()') ); | |||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||
| 266 | 5 | $entry->request($request); | |||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||
| 268 | 5 | return; | |||||||||||||||||||||||||||
| 269 | } | ||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||
| 271 | 5 | ▶ | sub _xml_response { | ||||||||||||||||||||||||||
|
Subroutine
_xml_response: called CC=12 SCAR=24.8
| |||||||||||||||||||||||||||||
| 272 | 5 | my ( $self, $ie_entry, $entry ) = @_; | |||||||||||||||||||||||||||
| 273 | 5 | foreach my $ie_response ( $ie_entry->getChildrenByTagName('response') ) { | |||||||||||||||||||||||||||
| 274 | 5 | my $response = $entry->response(); | |||||||||||||||||||||||||||
| 275 | 5 | foreach my $ie_status ( $ie_response->getChildrenByTagName('status') ) { | |||||||||||||||||||||||||||
| 276 | 5 | $response->status( $ie_status->findvalue('text()') ); | |||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||
| 278 | 5 | foreach my $ie_status_text ( | |||||||||||||||||||||||||||
| 279 | $ie_response->getChildrenByTagName('statusText') ) | ||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||
| 281 | 5 | $response->status_text( $ie_status_text->findvalue('text()') ); | |||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||
| 283 | 5 | foreach | |||||||||||||||||||||||||||
| 284 | my $ie_version ( $ie_response->getChildrenByTagName('httpVersion') ) | ||||||||||||||||||||||||||||
| 285 | { | ||||||||||||||||||||||||||||
| 286 | 5 | $response->http_version( $ie_version->findvalue('text()') ); | |||||||||||||||||||||||||||
| 287 | } | ||||||||||||||||||||||||||||
| 288 | 5 | $self->_xml_cookies( $ie_response, $response ); | |||||||||||||||||||||||||||
| 289 | 5 | $self->_xml_headers( $ie_response, $response ); | |||||||||||||||||||||||||||
| 290 | 5 | foreach my $ie_content ( $ie_response->getChildrenByTagName('content') ) | |||||||||||||||||||||||||||
| 291 | { | ||||||||||||||||||||||||||||
| 292 | 5 | my $content = Archive::Har::Entry::Response::Content->new(); | |||||||||||||||||||||||||||
| 293 | 5 | foreach | |||||||||||||||||||||||||||
| 294 | my $ie_mime_type ( $ie_content->getChildrenByTagName('mimeType') ) | ||||||||||||||||||||||||||||
| 295 | { | ||||||||||||||||||||||||||||
| 296 | 5 | $content->mime_type( $ie_mime_type->findvalue('text()') ); | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | 5 | foreach my $ie_text ( $ie_content->getChildrenByTagName('text') ) { | |||||||||||||||||||||||||||
| 299 | 3 | $content->text( $ie_text->findvalue('text()') ); | |||||||||||||||||||||||||||
| 300 | } | ||||||||||||||||||||||||||||
| 301 | 5 | foreach my $ie_size ( $ie_content->getChildrenByTagName('size') ) { | |||||||||||||||||||||||||||
| 302 | 5 | $content->size( $ie_size->findvalue('text()') ); | |||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||
| 304 | 5 | $response->content($content); | |||||||||||||||||||||||||||
| 305 | } | ||||||||||||||||||||||||||||
| 306 | 5 | foreach my $ie_redirect_url ( | |||||||||||||||||||||||||||
| 307 | $ie_response->getChildrenByTagName('redirectionURL') ) | ||||||||||||||||||||||||||||
| 308 | { | ||||||||||||||||||||||||||||
| 309 | 5 | $response->redirect_url( $ie_redirect_url->findvalue('text()') ); | |||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||
| 311 | 5 | foreach my $ie_headers_size ( | |||||||||||||||||||||||||||
| 312 | $ie_response->getChildrenByTagName('headersSize') ) | ||||||||||||||||||||||||||||
| 313 | { | ||||||||||||||||||||||||||||
| 314 | 5 | $response->headers_size( $ie_headers_size->findvalue('text()') ); | |||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | 5 | foreach | |||||||||||||||||||||||||||
| 317 | my $ie_body_size ( $ie_response->getChildrenByTagName('bodySize') ) | ||||||||||||||||||||||||||||
| 318 | { | ||||||||||||||||||||||||||||
| 319 | 5 | $response->body_size( $ie_body_size->findvalue('text()') ); | |||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||
| 321 | 5 | $entry->response($response); | |||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||
| 323 | 5 | return; | |||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||
| 326 | 2 | ▶ | sub _xml_entries { | ||||||||||||||||||||||||||
|
Subroutine
_xml_entries: called CC=9 SCAR=22.0
| |||||||||||||||||||||||||||||
| 327 | 2 | my ( $self, $ie_log ) = @_; | |||||||||||||||||||||||||||
| 328 | 2 | foreach my $ie_entries ( $ie_log->getChildrenByTagName('entries') ) { | |||||||||||||||||||||||||||
| 329 | 2 | my @entries; | |||||||||||||||||||||||||||
| 330 | 2 | foreach my $ie_entry ( $ie_entries->getChildrenByTagName('entry') ) { | |||||||||||||||||||||||||||
| 331 | 5 | my $entry = Archive::Har::Entry->new(); | |||||||||||||||||||||||||||
| 332 | 5 | foreach | |||||||||||||||||||||||||||
| 333 | my $ie_pageref ( $ie_entry->getChildrenByTagName('pageref') ) | ||||||||||||||||||||||||||||
| 334 | { | ||||||||||||||||||||||||||||
| 335 | 5 | $entry->pageref( $ie_pageref->findvalue('text()') ); | |||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||
| 337 | 5 | foreach my $ie_started ( | |||||||||||||||||||||||||||
| 338 | $ie_entry->getChildrenByTagName('startedDateTime') ) | ||||||||||||||||||||||||||||
| 339 | { | ||||||||||||||||||||||||||||
| 340 | 5 | $entry->started_date_time( $ie_started->findvalue('text()') ); | |||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||
| 342 | 5 | foreach | |||||||||||||||||||||||||||
| 343 | my $ie_timings ( $ie_entry->getChildrenByTagName('timings') ) | ||||||||||||||||||||||||||||
| 344 | { | ||||||||||||||||||||||||||||
| 345 | 5 | my $timings = Archive::Har::Entry::Timings->new(); | |||||||||||||||||||||||||||
| 346 | 5 | foreach | |||||||||||||||||||||||||||
| 347 | my $ie_send ( $ie_timings->getChildrenByTagName('send') ) | ||||||||||||||||||||||||||||
| 348 | { | ||||||||||||||||||||||||||||
| 349 | 5 | $timings->send( $ie_send->findvalue('text()') ); | |||||||||||||||||||||||||||
| 350 | } | ||||||||||||||||||||||||||||
| 351 | 5 | foreach | |||||||||||||||||||||||||||
| 352 | my $ie_wait ( $ie_timings->getChildrenByTagName('wait') ) | ||||||||||||||||||||||||||||
| 353 | { | ||||||||||||||||||||||||||||
| 354 | 5 | $timings->wait( $ie_wait->findvalue('text()') ); | |||||||||||||||||||||||||||
| 355 | } | ||||||||||||||||||||||||||||
| 356 | 5 | foreach my $ie_receive ( | |||||||||||||||||||||||||||
| 357 | $ie_timings->getChildrenByTagName('receive') ) | ||||||||||||||||||||||||||||
| 358 | { | ||||||||||||||||||||||||||||
| 359 | 5 | $timings->receive( $ie_receive->findvalue('text()') ); | |||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | 5 | $entry->timings($timings); | |||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||
| 363 | 5 | $self->_xml_request( $ie_entry, $entry ); | |||||||||||||||||||||||||||
| 364 | 5 | $self->_xml_response( $ie_entry, $entry ); | |||||||||||||||||||||||||||
| 365 | 5 | push @entries, $entry; | |||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||
| 367 | 2 | $self->entries( \@entries ); | |||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | 2 | return; | |||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||
| 372 | 2 | ▶ | sub xml { | ||||||||||||||||||||||||||
|
Subroutine
xml: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 373 | 2 | my ( $self, $xml ) = @_; | |||||||||||||||||||||||||||
| 374 | 2 | my $parser = XML::LibXML->new(); | |||||||||||||||||||||||||||
| 375 | 2 | my $ie_dom = $parser->parse_string($xml); | |||||||||||||||||||||||||||
| 376 | 2 | my $ie_log = $ie_dom->documentElement(); | |||||||||||||||||||||||||||
| 377 | 2 | $self->_init(); | |||||||||||||||||||||||||||
| 378 | 2 | foreach my $ie_version ( $ie_log->getChildrenByTagName('version') ) { | |||||||||||||||||||||||||||
| 379 | 2 | $self->version( $ie_version->findvalue('text()') ); | |||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||
| 381 | 2 | $self->_xml_creator($ie_log); | |||||||||||||||||||||||||||
| 382 | 2 | $self->_xml_browser($ie_log); | |||||||||||||||||||||||||||
| 383 | 2 | $self->_xml_pages($ie_log); | |||||||||||||||||||||||||||
| 384 | 2 | $self->_xml_entries($ie_log); | |||||||||||||||||||||||||||
| 385 | 2 | return; | |||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | 105 | ▶ | sub version { | ||||||||||||||||||||||||||
|
Subroutine
version: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 389 | 105 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 390 | 105 | my $old = $self->{log}->{version}; | |||||||||||||||||||||||||||
| 391 | 105 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 392 | 16 | $self->{log}->{version} = $new; | |||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||
| 394 | 105 | ▶ | if ( defined $old ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 395 | 23 | return $old; | |||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||
| 397 | else { | ||||||||||||||||||||||||||||
| 398 | 82 | return '1.1'; | |||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | 122 | ▶ | sub creator { | ||||||||||||||||||||||||||
|
Subroutine
creator: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 403 | 122 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 404 | 122 | my $old = $self->{log}->{creator}; | |||||||||||||||||||||||||||
| 405 | 122 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 406 | 16 | $self->{log}->{creator} = $new; | |||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||
| 408 | 122 | return $old; | |||||||||||||||||||||||||||
| 409 | } | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | 121 | ▶ | sub browser { | ||||||||||||||||||||||||||
|
Subroutine
browser: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 412 | 121 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 413 | 121 | my $old = $self->{log}->{browser}; | |||||||||||||||||||||||||||
| 414 | 121 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 415 | 9 | $self->{log}->{browser} = $new; | |||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||
| 417 | 121 | return $old; | |||||||||||||||||||||||||||
| 418 | } | ||||||||||||||||||||||||||||
| 419 | |||||||||||||||||||||||||||||
| 420 | 145 | ▶ | sub pages { | ||||||||||||||||||||||||||
|
Subroutine
pages: called CC=6 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 421 | 145 | my ( $self, $new ) = @_; | |||||||||||||||||||||||||||
| 422 | 145 | my $old = $self->{log}->{pages}; | |||||||||||||||||||||||||||
| 423 | 145 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 424 | 13 | ▶ | if ( defined $new ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 425 | 13 | $self->{log}->{pages} = []; | |||||||||||||||||||||||||||
| 426 | 13 | my $page_count = 0; | |||||||||||||||||||||||||||
| 427 | 13 | foreach my $page ( @{$new} ) { | |||||||||||||||||||||||||||
| 428 | 12 | ▶ | if ( !defined $page->{id} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 429 | 2 | $page->{id} = 'page_' . $page_count; | |||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||
| 431 | 12 | push @{ $self->{log}->{pages} }, Archive::Har::Page->new($page); | |||||||||||||||||||||||||||
| 432 | 12 | $page_count += 1; | |||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||
| 436 | 145 | ▶ | if ( defined $old ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 437 | 79 | return @{$old}; | |||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||
| 439 | else { | ||||||||||||||||||||||||||||
| 440 | 66 | return (); | |||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | 163 | ▶ | sub entries { | ||||||||||||||||||||||||||
|
Subroutine
entries: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||
| 445 | 163 | my ( $self, $entries ) = @_; | |||||||||||||||||||||||||||
| 446 | 163 | ▶ | my $old = $self->{log}->{entries} || []; | ||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'log'}{'entries'} || []
MC/DC100%1/1
$self->{'log'}{'entries'} || []
$self->{'log'}{'entries'}
Truth table100%2/2
A
A= $self->{'log'}{'entries'}
| |||||||||||||||||||||||||||||
| 447 | 163 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 448 | 16 | $self->{log}->{entries} = []; | |||||||||||||||||||||||||||
| 449 | 16 | foreach my $entry ( @{$entries} ) { | |||||||||||||||||||||||||||
| 450 | 172 | push @{ $self->{log}->{entries} }, Archive::Har::Entry->new($entry); | |||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||
| 453 | 163 | return @{$old}; | |||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||
| 456 | 103 | ▶ | sub comment { | ||||||||||||||||||||||||||
|
Subroutine
comment: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 457 | 103 | my ( $self, $comment ) = @_; | |||||||||||||||||||||||||||
| 458 | 103 | my $old = $self->{log}->{comment}; | |||||||||||||||||||||||||||
| 459 | 103 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 460 | 14 | $self->{log}->{comment} = $comment; | |||||||||||||||||||||||||||
| 461 | } | ||||||||||||||||||||||||||||
| 462 | 103 | return $old; | |||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||
| 465 | 85 | ▶ | sub TO_JSON { | ||||||||||||||||||||||||||
|
Subroutine
TO_JSON: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 466 | 85 | my ($self) = @_; | |||||||||||||||||||||||||||
| 467 | 85 | my $json = {}; | |||||||||||||||||||||||||||
| 468 | 85 | $json->{version} = $self->version(); | |||||||||||||||||||||||||||
| 469 | 85 | $json->{creator} = $self->creator(); | |||||||||||||||||||||||||||
| 470 | 85 | ▶ | if ( defined $self->browser() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 471 | 17 | $json->{browser} = $self->browser(); | |||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||
| 473 | 85 | ▶ | if ( defined $self->pages() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 474 | 32 | $json->{pages} = [ $self->pages() ]; | |||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||
| 476 | 85 | $json->{entries} = [ $self->entries() ]; | |||||||||||||||||||||||||||
| 477 | 85 | ▶ | if ( defined $self->comment() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 478 | 4 | $json->{comment} = $self->comment(); | |||||||||||||||||||||||||||
| 479 | } | ||||||||||||||||||||||||||||
| 480 | 85 | return { log => $json }; | |||||||||||||||||||||||||||
| 481 | } | ||||||||||||||||||||||||||||
| 482 | |||||||||||||||||||||||||||||
| 483 | 10 | 1; # End of Archive::Har | |||||||||||||||||||||||||||
| 484 | __END__ | ||||||||||||||||||||||||||||