sdyates has asked for the wisdom of the Perl Monks concerning the following question:

Using LWP, I cannot get past our MS Proxy. Here is my snippet of code:
use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->proxy(http => 'http://proxy.mgisoft.com:80'); my $req = new HTTP::Request ('GET', 'http://www.yahoo.com/'); $page = $ua->request($req)->as_string; print $page;
but, I get:
HTTP/1.1 407 (Proxy Authentication Required) Proxy Access Denied Date: Wed, 07 Feb 2001 17:04:47 GMT Proxy-Authenticate: NTLM Proxy-Authenticate: Basic realm="209.167.153.2" Server: Microsoft-IIS/4.0 Client-Date: Wed, 07 Feb 2001 17:07:57 GMT Client-Peer: 209.167.153.2:80 Client-Warning: Unsupported authentication scheme 'ntlm'
I must be missing something basic. I can't imagine I need a password as I am going through port 80. Please help, I have been working on this one for days! Thanks, Simon

Edit: 2001-03-03 by neshura

Replies are listed 'Best First'.
Re: LWP through Proxy
by footpad (Abbot) on Feb 08, 2001 at 00:34 UTC

    You said your code reports the following error:

    HTTP/1.1 407 (Proxy Authentication Required) Proxy Access Denied # stuff we don't need to know deleted. Proxy-Authenticate: NTLM Proxy-Authenticate: Basic realm="..." Client-Warning: Unsupported authentication scheme 'ntlm'

    The error message suggests you need to provide a username and password to the proxy server. Borrowing heavily from lwpcook, something like this might be in order:

    use LWP::UserAgent; $ua = new LWP::UserAgent; $ua->proxy(http => 'http://proxy.example.com:80'); $ua->proxy_authorization_basic( 'username', 'password' ); my $req = new HTTP::Request ('GET', 'http://www.yahoo.com/'); $page = $ua->request($req)->as_string; print $page;

    For what it's worth, this search provides a number of links to messages with a variety of related (and unrelated) information on the subject.

    Also, it would help if you checked out some of these links, which will help you understand the best way to use the Monastery:

    --f

(tye)Re: LWP through Proxy
by tye (Sage) on Feb 07, 2001 at 22:31 UTC

    Two suggestions. 1) Next time you get a chance to "preview", I suggest you use it. 2) Like I said in the chatterbox, go to Super Search. If you enter "msproxy" in the third box then hit the big button at the bottom of the form, you'll probably find an answer (really, I tried this and got it on my second try).

    Oh, and welcome to the Monastery. You aren't off to the best of starts, but that isn't uncommon and I hope others won't be too harsh on you for it. You might want to check out the site documentation including the FAQs.

    (And I didn't down-vote your node -- that would just be adding injury to insult.)

            - tye (but my friends call me "Tye")
Re: LWP through Proxy
by Caillte (Friar) on Feb 07, 2001 at 22:34 UTC

    The Great Larry defined laziness as a programmers virtue and he is so right. The information you have given us is probably all we need to answer your question but answer it we will not because we are all too lazy to try and work out what you wrote. Please edit your question and format it with html tags and we will all be happy to have a look :)

    $japh->{'Caillte'} = $me;