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

I have what seemed to me at first, a very simple question that would seemingly (and may still have) a trivial solution. However, I cannot find the information for this question anywhere--

I am making a simple cgi script that retrieves webpages written in PERL. I wanted to fetch them through a proxy server for the heck of it, but could not find out how. I've looked all over and the problem became more and more annoying to a point now that I HAVE to find the solution soon to keep my sanity. ! :)

I figured it would be something simple such as add the proxy addr and port somewhere in the header, but I can't find any information about it of course.

THe script works without proxys, that's not a problem. Just need the snippits that will allow a proxy connection and I'll be a happy camper.

I never looked at the DBI:proxy module and don't know if this will help. It may be the solution i'm avoiding, just looking for the simple answer.

Replies are listed 'Best First'.
Re: Proxy Experts Out There?
by sheth (Acolyte) on Sep 04, 2001 at 03:02 UTC
    You didn't mention if you were using LWP::UserAgent to fetch the pages, but, if that is the case, then it's simply a matter of setting the proxy in the user agent object.

    First, create the user agent:
    $ua = new LWP::UserAgent;

    Next, set the proxy in the user agent:
    $ua->proxy('http', 'http://proxy.mylocalproxy.com:8001/');

    Then, do the request:
    $ua->simple_request($request)

    Note: The docuemntation gives more details: The $request should be a reference to a HTTP::Request object with values defined for at least the method() and uri() attributes.
      If you have global proxy setting in your environment already (http_proxy,no_proxy and friends), you can also use env_proxy() to get them:

      $ua->env_proxy();

      I recommend man LWP::UserAgent .