| 1 | package WWW::Mechanize::Script::Plugin::ContentSizeTest; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use parent qw(WWW::Mechanize::Script::Plugin); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | # ABSTRACT: check for size of received content | ||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | our $VERSION = '0.100'; | |||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 2 | ▶ | use 5.014; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | sub check_value_names | ||||||||||||||||||||||||||||
| 16 | 5 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
check_value_names: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 5 | return qw(min_bytes max_bytes); | |||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | sub check_response | ||||||||||||||||||||||||||||
| 22 | 1 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
check_response: called CC=9 SCAR=33.5
Pod
documented
| |||||||||||||||||||||||||||||
| 23 | 1 | my ( $self, $check, $mech ) = @_; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 1 | my $code = 0; | |||||||||||||||||||||||||||
| 26 | 1 | my $msg; | |||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 1 | my $min_bytes = 0 + $self->get_check_value( $check, "min_bytes" ); | |||||||||||||||||||||||||||
| 29 | 1 | my $max_bytes = 0 + $self->get_check_value( $check, "max_bytes" ); | |||||||||||||||||||||||||||
| 30 | 1 | my $content_len = length $mech->response()->content(); | |||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | 1 | ▶ | if ( defined($min_bytes) and $min_bytes > $content_len ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $min_bytes and $min_bytes > $content_len
MC/DC0%0/2
defined $min_bytes and $min_bytes > $content_len
defined $min_bytes
$min_bytes > $content_len
Truth table33%1/3
A and B
A= defined $min_bytesB= $min_bytes > $content_len
| |||||||||||||||||||||||||||||
| 33 | { | ||||||||||||||||||||||||||||
| 34 | 0 | ▶ | my $err_code = $self->get_check_value( $check, "min_bytes_code" ) // 1; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->get_check_value($check, "min_bytes_code") // 1
MC/DC0%0/1
$self->get_check_value($check, "min_bytes_code") // 1
$self->get_check_value($check, "min_bytes_code")
Truth table0%0/2
A
A= $self->get_check_value($check, "min_bytes_code")
| |||||||||||||||||||||||||||||
| 35 | 0 | $code = &{ $check->{compute_code} }( $code, $err_code ); | |||||||||||||||||||||||||||
| 36 | 0 | $msg = "received $content_len bytes exceeds lower threshold ($min_bytes)"; | |||||||||||||||||||||||||||
| 37 | } | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | 1 | ▶ | if ( defined($max_bytes) and $max_bytes < $content_len ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $max_bytes and $max_bytes < $content_len
MC/DC0%0/2
defined $max_bytes and $max_bytes < $content_len
defined $max_bytes
$max_bytes < $content_len
Truth table33%1/3
A and B
A= defined $max_bytesB= $max_bytes < $content_len
| |||||||||||||||||||||||||||||
| 40 | { | ||||||||||||||||||||||||||||
| 41 | 0 | ▶ | my $err_code = $self->get_check_value( $check, "max_bytes_code" ) // 1; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->get_check_value($check, "max_bytes_code") // 1
MC/DC0%0/1
$self->get_check_value($check, "max_bytes_code") // 1
$self->get_check_value($check, "max_bytes_code")
Truth table0%0/2
A
A= $self->get_check_value($check, "max_bytes_code")
| |||||||||||||||||||||||||||||
| 42 | 0 | $code = &{ $check->{compute_code} }( $code, $err_code ); | |||||||||||||||||||||||||||
| 43 | 0 | ▶ | if ($msg) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | { | ||||||||||||||||||||||||||||
| 45 | 0 | $msg .= " and upper threshold ($max_bytes )"; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | else | ||||||||||||||||||||||||||||
| 48 | { | ||||||||||||||||||||||||||||
| 49 | 0 | $msg = "received $content_len bytes exceeds upper limit ($max_bytes)"; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 1 | ▶ | return ( $code, ( $msg ? ($msg) : () ) ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 2 | 1; | |||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | __END__ | ||||||||||||||||||||||||||||