Dezi-App

 view release on metacpan or  search on metacpan

lib/Dezi/Aggregator/Spider.pm  view on Meta::CPAN

        if ( $self->follow_redirects ) {
            $self->_add_links( $uri,
                URI->new_abs( $location, $http_response->base ) );
        }
        return $response->status;
    }

    if ( $response->ct ) {
        $self->debug and $self->write_log(
            uri => $uri,
            msg => 'content-type: ' . $response->ct,
        );
    }

    # add its links to the queue.
    # If the resource looks like an XML feed of some kind,
    # glean its links differently than if it is an HTML response.
    if ( my $feed = $self->looks_like_feed($http_response) ) {
        $self->debug and $self->write_log(
            uri => $uri,
            msg => 'looks like feed'

lib/Dezi/Aggregator/Spider/Response.pm  view on Meta::CPAN

Shortcut for $response->http_response->code.

=cut

sub status {
    return shift->http_response->code;
}

=head2 ct

Shortcut for $response->response->header('content-type').
Any encoding will be stripped from the returned string.

=cut

sub ct {
    my $self = shift;
    my $ct   = $self->http_response->header('content-type');
    $ct =~ s/;.+// if $ct;
    return $ct;
}

=head2 is_html

Returns true if ct() looks like HTML or XHTML.

=cut

lib/Dezi/Aggregator/Spider/Response.pm  view on Meta::CPAN


=cut

sub title {
    my $self = shift;
    return unless $self->is_html;

    my $p = HTML::HeadParser->new;

    # HTML::HeadParser throws warning if utf-8 flag is not on for utf-8 bytes.
    # So we trust the content-type header and
    # verify that the utf-8 flag is on.
    if ( $self->http_response->header('content-type') =~ m/utf-8/i ) {
        $p->parse( to_utf8( $self->content ) );
    }
    else {
        $p->parse( $self->content );
    }
    return $p->header('Title');
}

# delegate all other method calls to the http_response object.
# cribbed from HTTP::Message



( run in 1.054 second using v1.01-cache-2.11-cpan-524268b4103 )