Hi All,
 
This is for my work.  Any suggestions or input would be greatly appreciated.
 
I've been trying to use LWP module to access an https web and download a file with no luck so far -- the script works fine for http web, while it threw out an error for https web -- I worked behind our company's firewall.  So I'd have to use proxy server (I got to know this while I was debugging my script, it threw out an error message LWP::UserAgent::_need_proxy: No proxy, so I guess I'd have to use a proxy for this.  But still stumped as the proxy doesn't seem to be working).  Here is my script and the error message I got:
(I'm using perl5.8.0 and it's RedHat Linux 7.2).
 
===========================
Script
===========================
use HTTP::Request::Common;
use LWP::UserAgent qw($ua);
use LWP::Debug qw(+);
 
$ua = LWP::UserAgent->new;
$ua->credentials("https://www.XXXX.com/login/log_log_page.jsp:80",
                 "admin",
                 "XXX" => "XXX"
                );  # authentication
 
$ua->proxy('https'=>"http://XX.XXX.XXX.XXX:8010");  # I'm not sure if this caused the problem -- I used the server (on which I ran the script) IP as the proxy; 
 
 my $request = HTTP::Request->new(GET => "https://www.XXXX.com/XXXinfo/xxxx.jsp");   # this is the file I have to download for work 
 my $response = $ua->request($request, "./tmp.txt");
 LWP::Debug::conns("Get Response");
 
 print "Response is: ".$response->status_line."\n";
 if ($response->is_success) {
     print "Successfully updated BIN file: /tmp.txt\n";
 }
 else {
     $response->status_line;
 }
 
__END__
 
============
Error Message:
============
LWP::UserAgent::request: Simple response: Internal Server Error
Response is: 500 Can't connect to XX.XX.XX.XXX:8010 (connect: Connection refused)
 
I read almost all the posts on this forum (related to this topic) and all the materials that were suggested (like lwp-cookbook, and all docs for CPAN LWP modules) in the past 3 days, but still couldn't have my problem solved.  Could anybody take a quick look at my following questions and drop me an answer?  Thanks in advance.
 
1) Could someone kindly point out my mistakes (if there are any) in the small script?
 
2) As I'm a newbie on using perl to handle networking issues and still trying to figure out which proxy I should use.  Does someone know if it's a MUST to use a proxy if I wanna access to an https web from behind our company's firewall?  Usually, how do I know which proxy should be used?  Can I check the system settings to track this down or I do have to contact my system admin for this? 
 
Thanks a lot!
 
Regards,
Tulip
_______________________________________________
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to