Back in the early to mid-2000s, I built a bunch of Perl scripts for clients that imported a PHP script using:
# where $home is predefined with the current website address
use LWP::Simple;
$foo = get("$home/foo.php");
print foo;
I've only recently discovered that LWP::Simple doesn't support SSL scripts, so now that I'm forcing SSL on all pages those get() functions fail. They're not fatal errors, they just print nothing.
I believe that LWP::Simple has a method where you can ignore SSL, but I couldn't figure it out. And it would require a modification to every script, so it wouldn't be ideal for me, anyway.
I discovered that HTTP::Tiny works fine with SSL scripts, though, so I'm sharing my solutions with others.
If you only have a few scripts, then this modification works:
# remove LWP::Simple;
# use LWP::Simple;
# replace it with HTTP::Tiny
use HTTP::Tiny;
# alternative get()
sub get {
return HTTP::Tiny->new->get($_[0])->{content};
}
But in my case, I have several accounts that use LWP::Simple, and it's not practical to modify all of them manually if I don't have to. So instead, I modified LWP::Simple directly. I don't know if any OS or cPanel scripts use LWP::Simple, but I would be surprised if they did. So I'm making an educated guess here that this will be OK.
On my server, the path to the module is:
/usr/local/share/perl5/LWP/Simple.pm
but your path may be different. Be sure to make a backup of Simple.pm, just in case.
This is the get() section of the LWP::Simple module:
sub get ($)
{
my $response = $ua->get(shift);
return $response->decoded_content if $response->is_success;
return undef;
}
And this is my modification:
use HTTP::Tiny;
sub get ($) {
my $response = HTTP::Tiny->new->get(shift);
return $response->{content} if $response->{success};
return undef;
}
The docs on HTTP::Tiny:
[
metacpan.org...]
I suspect that this will be marginally slower than the original, but in my case they're all low traffic sites so it's OK (within reason, of course).
I welcome anyone else to post suggestions or warnings! For me this was a relatively quick fix on a problem that was hard to track down, though, so I'm hoping it can help others that might have the same problem.