| 1 | package OpenID::Lite::RelyingParty::Discover::Fetcher::Yadis; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use Any::Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 3 | with 'OpenID::Lite::Role::AgentHandler'; | |||||||||||||||||||||||||||
| 5 | 3 | with 'OpenID::Lite::Role::ErrorHandler'; | |||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use OpenID::Lite::RelyingParty::Discover::Fetcher::Yadis::HTMLExtractor; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use OpenID::Lite::RelyingParty::Discover::FetchResult; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | use OpenID::Lite::Constants::Yadis | ||||||||||||||||||||||||||||
| 10 | 3 | ▶ | qw(XRDS_HEADER YADIS_HEADER XRDS_CONTENT_TYPE); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 1 | ▶ | sub fetch { | ||||||||||||||||||||||||||
|
Subroutine
fetch: called CC=6 SCAR=24.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 13 | 1 | my ( $self, $uri ) = @_; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | 1 | my $res = $self->agent->get( $uri, 'Accept' => XRDS_CONTENT_TYPE ); | |||||||||||||||||||||||||||
| 16 | 1 | ▶ | return $self->ERROR( sprintf q{Failed Yadis discovery on "%s"}, $uri ) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 17 | unless $res->is_success; | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 1 | my $result = OpenID::Lite::RelyingParty::Discover::FetchResult->new; | |||||||||||||||||||||||||||
| 20 | 1 | $result->normalized_identifier($uri); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 1 | my $content_type = $res->header('Content-Type'); | |||||||||||||||||||||||||||
| 23 | 1 | my $xrds_type = quotemeta XRDS_CONTENT_TYPE; | |||||||||||||||||||||||||||
| 24 | 1 | ▶ | if ( $content_type && $content_type =~ /^$xrds_type/i ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$content_type and $content_type =~ /^$xrds_type/i
MC/DC0%0/2
$content_type and $content_type =~ /^$xrds_type/i
$content_type
$content_type =~ /^$xrds_type/i
Truth table33%1/3
A and B
A= $content_typeB= $content_type =~ /^$xrds_type/i
| |||||||||||||||||||||||||||||
| 25 | 0 | $result->content_type( lc $content_type ); | |||||||||||||||||||||||||||
| 26 | 0 | $result->final_url( $res->base->as_string ); | |||||||||||||||||||||||||||
| 27 | 0 | $result->content( $res->content ); | |||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||
| 29 | else { | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 1 | ▶ | my $yadis_location = $self->_extract_location($res) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 32 | or return $self->ERROR( | ||||||||||||||||||||||||||||
| 33 | sprintf q{Failed Yadis discovery for url "%s"}, $uri ); | ||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | $res = $self->agent->get($yadis_location); | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | return $self->ERROR( sprintf q{Failed Yadis discovery for url "%s"}, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | $yadis_location ) | ||||||||||||||||||||||||||||
| 38 | unless $res->is_success; | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 0 | $result->content_type( lc $res->header('Content-Type') ); | |||||||||||||||||||||||||||
| 41 | 0 | $result->final_url( $res->base->as_string ); | |||||||||||||||||||||||||||
| 42 | 0 | $result->content( $res->content ); | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | 0 | return $result; | |||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 1 | ▶ | sub _extract_location { | ||||||||||||||||||||||||||
|
Subroutine
_extract_location: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||
| 48 | 1 | my ( $self, $res ) = @_; | |||||||||||||||||||||||||||
| 49 | 1 | ▶ | return $self->_extract_location_from_header($res) | ||||||||||||||||||||||||||
|
Condition33%1/3
$self->_extract_location_from_header($res) || $self->_extract_location_from_html($res->content)
MC/DC0%0/2
$self->_extract_location_from_header($res) || $self->_extract_location_from_html($res->content)
$self->_extract_location_from_header($res)
$self->_extract_location_from_html($res->content)
Truth table33%1/3
A || B
A= $self->_extract_location_from_header($res)B= $self->_extract_location_from_html($res->content)
| |||||||||||||||||||||||||||||
| 50 | || $self->_extract_location_from_html( $res->content ); | ||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | 1 | ▶ | sub _extract_location_from_header { | ||||||||||||||||||||||||||
|
Subroutine
_extract_location_from_header: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||
| 54 | 1 | my ( $self, $res ) = @_; | |||||||||||||||||||||||||||
| 55 | 1 | ▶ | return $res->header(XRDS_HEADER) | ||||||||||||||||||||||||||
|
Condition33%1/3
$res->header('X-XRDS-Location') || $res->header('X-Yadis-Location')
MC/DC0%0/2
$res->header('X-XRDS-Location') || $res->header('X-Yadis-Location')
$res->header('X-XRDS-Location')
$res->header('X-Yadis-Location')
Truth table33%1/3
A || B
A= $res->header('X-XRDS-Location')B= $res->header('X-Yadis-Location')
| |||||||||||||||||||||||||||||
| 56 | || $res->header(YADIS_HEADER); | ||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 1 | ▶ | sub _extract_location_from_html { | ||||||||||||||||||||||||||
|
Subroutine
_extract_location_from_html: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 60 | 1 | my ( $self, $content ) = @_; | |||||||||||||||||||||||||||
| 61 | return | ||||||||||||||||||||||||||||
| 62 | 1 | OpenID::Lite::RelyingParty::Discover::Fetcher::Yadis::HTMLExtractor->extract($content); | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | 3 | 1; | |||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||