Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl LWP content request behind firewall and proxy server

Reply
Thread Tools

Perl LWP content request behind firewall and proxy server

 
 
demonhunter
Guest
Posts: n/a
 
      08-15-2004
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
 
Reply With Quote
 
 
 
 
Gunnar Hjalmarsson
Guest
Posts: n/a
 
      08-15-2004
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
 
Reply With Quote
 
 
 
 
demonhunter
Guest
Posts: n/a
 
      08-16-2004
Gunnar Hjalmarsson <(E-Mail Removed)> wrote in message news:<yUKTc.614$(E-Mail Removed)>...
> 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?
 
Reply With Quote
 
nobull@mail.com
Guest
Posts: n/a
 
      08-16-2004
http://www.velocityreviews.com/forums/(E-Mail Removed) (demonhunter) wrote in message news:<(E-Mail Removed). com>...
> 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 hostort";

This newsgroup does not exist (see FAQ). Please do not start threads
here.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to validate with W3C validation for intrAnet apps. (behind a firewall+proxy) Adrienne Boswell HTML 0 01-25-2008 03:20 AM
RMI client behind a firewall, server behind a firewall too Robert Dodier Java 6 09-14-2004 09:23 PM
Web Service invocation from behind proxy behind firewall Kumarforg ASP .Net Web Services 0 08-03-2004 07:15 AM
Help to set up tomcat 4.1.27 behind socks proxy to access database outside the proxy vidy5300 Java 0 06-07-2004 02:23 PM
Web Service Request from behind a Proxy/Firewall Rama ASP .Net Web Services 0 08-19-2003 01:34 PM



Advertisments