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

Hi, I'm using the following code to get a web page via a proxy. But I get the following message when I run it "Message: Protocol scheme 'http' is not supported". Any Ideas why, and what I have to do to solve it?
use LWP::UserAgent; $ua = LWP::UserAgent->new; $ua->proxy('http', 'http://my.proxy:8000/'); $request = HTTP::Request->new('GET', 'http://www.perlmonks.org'); $response = $ua->request($request); $bob = $response->as_string(); print "$bob \n";
Many thanks for any help. Chris

Replies are listed 'Best First'.
Re: Problems with UserAgent to get through proxy
by rob_au (Abbot) on Jan 17, 2002 at 18:10 UTC
    This code works fine on my system when I replace the $ua->proxy line with the appropriate proxy details for my network - It may be worthwhile examining your network and/or proxy configuration (It is a HTTP proxy that you are running on your network and not a SOCKS proxy?) or if this code is part of a larger script, posting a larger section of your code.

     

    perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'

      Ok I'll check things out. Thanks for your help. Chris
      Still doesn't work on mine and I get this error msg (in full);
      RC: 501 (Not Implemented) Message: Protocol scheme 'http' is not supported -----------------------------------
      Cheers Chris
        Well, with this 'error' message my inclination is to suggest that you find out more about the proxy which you are connecting through as it would seem that this is where the problem lies. What software is running the proxy? Is it a HTTP or a SOCKS proxy? Is there any authentication required for access? If you don't know the answers to these questions, it might be worth sounding out your network administrator to get an idea as to how the proxy is set up.

        Good luck.

         

        perl -e 's&&rob@cowsnet.com.au&&&split/[@.]/&&s&.com.&_&&&print'

Re: Problems with UserAgent to get through proxy
by PrakashK (Pilgrim) on Jan 17, 2002 at 19:16 UTC
    Try the script GET that is bundled with LWP.
    $ GET -p http://my.proxy:8000/ http://www.perlmonks.org
    GET uses LWP::UserAgent internally, so this would let you test your proxy setup quickly. Once you got that working, you might continue to work on your script.

    /prakash