WWW::BookBot::FakeCookies - Fake HTTP::Cookies to skip local file access.


WWW-BookBot documentation Contained in the WWW-BookBot distribution.

Index


Code Index:

NAME

Top

WWW::BookBot::FakeCookies - Fake HTTP::Cookies to skip local file access.

SYNOPSIS

Top

  use WWW::BookBot::FakeCookies;

ABSTRACT

Top

  Fake HTTP::Cookies to skip local file access.

DESCRIPTION

Top

HTTP::Cookies will die when fetching local files with LWP. The reason is that HTTP::Cookies want to access $url->port which does not exist.

WWW::BookBot::FakeCookies check $url->port before call HTTP::Cookies. If $url->port is unavailable, WWW::BookBot::FakeCookies will return without calling HTTP::Cookies.

EXPORT

None by default.

BUGS, REQUESTS, COMMENTS

Top

Please report any requests, suggestions or bugs via http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-BookBot

AUTHOR

Top

Qing-Jie Zhou <qjzhou@hotmail.com>

SEE ALSO

Top

WWW::BookBot


WWW-BookBot documentation Contained in the WWW-BookBot distribution.

package WWW::BookBot::FakeCookies;

use 5.008;
use strict;
use warnings;
use base qw(HTTP::Cookies);
use vars qw($VERSION);
$VERSION = '1.02';

sub add_cookie_header {
	my $self = shift;
    my $request = shift || return;
    my $url = $request->url;
    eval {$url->port;};
    return if $@;
    $self->SUPER::add_cookie_header($request);
}

sub extract_cookies
{
    my $self = shift;
    my $response = shift || return;
    my $request = $response->request;
    my $url = $request->url;
    eval {$url->port;};
    return if $@;
    $self->SUPER::extract_cookies($response);
}

1;
__END__