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

I am having a problem with a Perl routine that was working for years under 5.08. We recently upgraded to 5.14 and our HTTP calls are failing (OK, not failing, just not working as they did. Code snippet below.
my $url = "https://site.company.com/javaprog.jsp"; print LOGFILE localtime()."Url Value: *".$url."*\n"; my $request = HTTP::Request->new(GET => $url); my $ua = LWP::UserAgent->new; $ua->protocols_allowed( [ 'http', 'https'] ); my $response = $ua->request($request); if ($response->is_success) { print LOGFILE localtime()."\tSuccessfully initiated cache +reload via $url\n"; } else { $warningCnt++; $warningMsg=$warningMesg||" Unable to remove $filename fro +m $sshHost\n"; print LOGFILE localtime()."\tWARNING: Unable to intiate +cache refresh via $url\n"; print LOGFILE localtime()."\t\tDEBUG: $response \n"; }

The result being output to the log is: DEBUG: HTTP::Response=HASH(0x2cd1ae0)

I confess newness to Perl so please be gentle.

Replies are listed 'Best First'.
Re: HTTPS Problem
by tobyink (Canon) on Apr 24, 2012 at 00:26 UTC

    What version of LWP are you using? You can check via:

    perl -MLWP -E'say(LWP->VERSION)'

    As of LWP 6.02, you need to install LWP::Protocol::https separately to get HTTPS support. (LWP::Protocol::https used to be bundled with LWP, but as far as I understand it, has been unbundled because it has some heavy dependencies.)

    Assuming you're on a Linux/Unix-based machine, you can probably find LWP::Protocol::https through your package manager, or if not, you can probably install it using CPAN:

    sudo cpan LWP::Protocol::https

    By the way, your debugging output is fairly useless. You might want to try something like:

    printf LOGFILE "%s\t\tDEBUG: %s\n", localtime(), $response->as_string;
    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'
      Thanks. Looks like I'm at 6.02 so I'll go in that direction. It's a Windows box so I'll be using ppm to grab it. I'll update outcome whether good or bad.

      Thanks for the help, Jay.

        It looks like the problem was actually certificate verfication. I'm guessing that the earlier release we upgraded away from defaulted the ssl_opts key verify_hostname to FALSE. LWP 6.02 defaults to TRUE. Everything is working fine now thanks to the hint on the debug output.