Perl LWP content request behind firewall and proxy server

Discussion in 'Perl' started by demonhunter, Aug 15, 2004.

  1. demonhunter

    demonhunter Guest

    Hi,
    I am trying to fetch a web content using LWP and HTTP modules behind
    corp firewall. I set proxy server as shown in my internet explorer
    connection setup.
    When i run the script, i got successful response, but the return
    content is not the webpage i requested at all. It shows something
    like:
    -------------------------------------------------
    function FindProxyForURL(url,host) {
    me=myIpAddress();
    if (me == "127.0.0.1") {return "DIRECT";}
    if (host == "127.0.0.1") {return "DIRECT";}
    if (host == "localhost") {return "DIRECT";}
    if (isPlainHostName(host)) {return "DIRECT";}
    ..
    ..
    ..
    ---------------------------------------------------

    Below is my sample script:
    require LWP::UserAgent;
    require HTTP::Request;

    my $ua = LWP::UserAgent->new;
    $ua->timeout(10);
    $ua->proxy(['http', 'ftp'], 'http://autoproxy:9090');

    my $request = HTTP::Request->new(POST => 'http://www.google.com');
    my $response = $ua->request($request);
    if ($response->is_success) {
    print $response->content; # or whatever
    }
    else {
    die $response->status_line;
    }

    Anyone can help me on this? will appreciate.

    by,
    demon hunter
    demonhunter, Aug 15, 2004
    #1
    1. Advertising

  2. demonhunter wrote:
    > I am trying to fetch a web content using LWP and HTTP modules
    > behind corp firewall.


    <snip>

    > my $request = HTTP::Request->new(POST => 'http://www.google.com');

    ------------------------------------^^^^

    A POST request to get a web page?

    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl
    Gunnar Hjalmarsson, Aug 15, 2004
    #2
    1. Advertising

  3. demonhunter

    demonhunter Guest

    Gunnar Hjalmarsson <> wrote in message news:<yUKTc.614$>...
    > demonhunter wrote:
    > > I am trying to fetch a web content using LWP and HTTP modules
    > > behind corp firewall.

    >
    > <snip>
    >
    > > my $request = HTTP::Request->new(POST => 'http://www.google.com');

    > ------------------------------------^^^^
    >
    > A POST request to get a web page?


    Oh, that suppose to be a GET, i did some changes here and there when
    it doesnt work in GET. And it gave me the same
    "FindProxyForURL(url,host)" content. Any idea why?
    demonhunter, Aug 16, 2004
    #3
  4. demonhunter

    Guest

    (demonhunter) wrote in message news:<>...
    > I am trying to fetch a web content using LWP and HTTP modules behind
    > corp firewall. I set proxy server as shown in my internet explorer
    > connection setup.


    > $ua->proxy(['http', 'ftp'], 'http://autoproxy:9090');


    > When i run the script, i got successful response, but the return
    > content is not the webpage i requested at all. It shows something
    > like:
    > -------------------------------------------------
    > function FindProxyForURL(url,host) {
    > me=myIpAddress();
    > if (me == "127.0.0.1") {return "DIRECT";}
    > if (host == "127.0.0.1") {return "DIRECT";}
    > if (host == "localhost") {return "DIRECT";}
    > if (isPlainHostName(host)) {return "DIRECT";}
    > .
    > .
    > .
    > ---------------------------------------------------


    Go back and look at the internet explorer connection setup again.

    Where did you see 'http://autoproxy:9090'?

    I suspect it was not the address of the proxy. I suspect was the URL
    of the proxy autoconfiguration script. I further suppose that tje
    HTTP server at autoproxy:9090 is very simplistic and just returns the
    PAC in response to all GET requests.

    AFAIK LWP doesn't understand PACs (because it would require a full
    JavaScript subsystem). (Actually there are people working on
    JavaScript for LWP so one day soon there may be PAC support).

    To figure out the address of the proxy examine the PAC yourself and
    look for a line that says:

    return "PROXY host:port";

    This newsgroup does not exist (see FAQ). Please do not start threads
    here.
    , Aug 16, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Dodier
    Replies:
    6
    Views:
    2,342
    Matthias Kraft
    Sep 14, 2004
  2. Replies:
    1
    Views:
    17,096
  3. Adrienne Boswell
    Replies:
    0
    Views:
    462
    Adrienne Boswell
    Jan 25, 2008
  4. Rama

    Web Service Request from behind a Proxy/Firewall

    Rama, Aug 19, 2003, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    133
  5. Kumarforg

    Web Service invocation from behind proxy behind firewall

    Kumarforg, Aug 3, 2004, in forum: ASP .Net Web Services
    Replies:
    0
    Views:
    181
    Kumarforg
    Aug 3, 2004
Loading...

Share This Page