in reply to Re: authenticate to a proxy server [Again!]
in thread authenticate to a proxy server [Again!]

Thank you everyone for your replies and patience. But my program doesn't work. Here is my code

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.

Replies are listed 'Best First'.
Re: Re: Re: authenticate to a proxy server [Again!]
by toma (Vicar) on Feb 23, 2003 at 17:59 UTC
    Perhaps your proxy is using WebDoubler or something similar. The script you are getting is a chunk of JavaScript that is sent to the browser for automatic proxy detection.

    The identity of your real proxy server is in the return value of the function:

    proxy.mycompany.intranet:8080
    So the proper configuration is:
    $ua->proxy(['http'],'http://proxy.mycompany.intranet:8080/');
    I found this with a Google search on FindProxyForURL. A good trick for figuring things out is to type your error message into Google.

    It should work perfectly the first time! - toma