Re: Requests from different IP addresses?
Gisle Aas (gisle@activestate.com)
12 Jan 2001 11:11:38 -0800
"Derek J. Balling" <dballing@yahoo-inc.com> writes:
> At 10:31 AM -0800 1/12/01, Gisle Aas wrote:
> >Stefan Kruger <stefan@inty.co.uk> writes:
> >
> >> For a machine with several IP-addresses, is it possible
> >> to specify from which a HTTP::Request is sent?
> >
> >You can set the (undocumented) variable
> >@LWP::Protocol::http::EXTRA_SOCK_OPTS to specify LocalAddr. This
> >variable contains additional parameters that are always passed to
> >IO::Socket::INET's constructor.
> >
> >Something like this:
> >
> > @LWP::Protocol::http::EXTRA_SOCK_OPTS = (LocalAddr => 'xxxxxxx');
> >
> > # The normal drill
> > use LWP;
> > my $ua = LWP::UserAgent->new;
> > my $res = $ua->request(HTTP::Request->new(GET => "http://www.perl.org"));
> >
> > print $res->as_string;
>
> Wouldn't that @LWP assignment have to come AFTER the 'use LWP'?
It should not matter. LWP will not override this value if it is
already set.
Regards,
Gisle