[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] LWP (anyone use it through a firewall?)



At 10:44 PM 98.04.14, Craig Muth wrote:
> Hello,
>
>     I hate to ask the same question twice, but I have read the LWP
> cookbook, and tried the example, but it doesn't work.  Has anyone out
> there successfully used LWP through a firewall?  I can get() a file from
> inside the firewall, but not outside.
>     My proxy settings are correct in "Internet Config" (I even tried to
> override them with get(http://proxy:port/www.foo.bar)) and I'm using the
> latest version of MacPerl.


I guess you are using LWP::Simple module, no? The LWP::Simple is actually a
simplified interface to LWP::UserAgent, and you should use LWP::UserAgent
instead of LWP::Simple, when you need to do something just more than the
simplest getting url work.

A sample code for using proxy should be something like this :

use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;

my $ua = new LWP::UserAgent;
$ua->proxy('http', 'http://proxy.yours.com:port/'); # specify your proxy server
$ua->no_proxy('yours.com');  #no proxy for requests within your domain

my($url) = @_;

my $request = new HTTP::Request ('GET', $url);
my $response = $ua->request($request);

if ($response->is_success) {
    print $response->content ;
   } else {
    print $response->error_as_HTML;
}


Takashi Ikemi,
ikemi@xa2.so-net.ne.jp



***** Want to unsubscribe from this list?
***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch