NAME

LWP::UserAgent::DNS::Hosts - Override LWP HTTP/HTTPS request's host like /etc/hosts

SYNOPSIS

use LWP::UserAgent;
use LWP::UserAgent::DNS::Hosts;

# add entry
LWP::UserAgent::DNS::Hosts->register_host(
    'www.cpan.org' => '127.0.0.1',
);

# add entries
LWP::UserAgent::DNS::Hosts->register_hosts(
    'search.cpan.org' => '192.168.0.100',
    'pause.perl.org'  => '192.168.0.101',
);

# read hosts file
LWP::UserAgent::DNS::Hosts->read_hosts('/path/to/my/hosts');

LWP::UserAgent::DNS::Hosts->enable_override;

# override request hosts with peer addr defined above
my $ua  = LWP::UserAgent->new;
my $res = $ua->get("http://www.cpan.org/");
print $res->content; # is same as "http://127.0.0.1/" content

DESCRIPTION

LWP::UserAgent::DNS::Hosts is a module to override HTTP/HTTPS request peer addresses that uses LWP::UserAgent.

This module concept was got from LWP::Protocol::PSGI.

METHODS

AUTHOR

NAKAGAWA Masaki masaki@cpan.org

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

LWP::Protocol, LWP::Protocol::http, LWP::Protocol::https