use strict;
use warnings;
use LWP::UserAgent;
my $content;
my $ua = new LWP::UserAgent;
$ua->proxy(['http'], 'http://my_username:my_pwd@proxy.mycompany.intran
+et/autoproxy:8080/');
$ua->agent("Mozilla/6.0");
my $req = new HTTP::Request(GET => 'http://www.perlmonks.com/');
my $res = $ua->request($req);
print $res->content if ($res->is_success);
I also tried another variation. I set 3 environment variables
HTTP_PROXY=http://proxy.mycompany.intranet/autoproxy:8080/
HTTP_proxy_pass=my_username
HTTP_proxy_user=my_pwd
Now I changed the code to
use strict;
use warnings;
use LWP::UserAgent;
my $content;
my $ua = new LWP::UserAgent;
$ua->env_proxy();
$ua->agent("Mozilla/6.0");
my $req = new HTTP::Request(GET => 'http://www.perlmonks.com/');
my $res = $ua->request($req);
print $res->content if ($res->is_success);
It still didn't work!
When I run this program it does not print the contents of the perlmonks page. It prints a script file on my console. This is exactly the same output which I used to get in my C# program till I had configured the proxy authentication properly.
Currently the output of running my perl code is
function FindProxyForURL (url, host)
{
if (
shExpMatch (host, "127.0.0.1") ||
isPlainHostName(host) ||
dnsDomainIs(host,"mycompany.intranet") ||
shExpMatch(host,"xy.xyz.*") ||
)
return "DIRECT";
return "PROXY proxy.mycompany.intranet:8080";
}
Regarding starting a new thread and not posting it to the old one, I did so because I was afraid, that if i post on the old thread no one will read it unless they go down to that date. If i start a new one then it will appear in the newest node where there is more probability of monks reading my question.
regards,
Abhishek.
|