0
votes

The below returns

[HTTP::Response=HASH(0x2ad70dc)] [LWP will support https URLs if the LWP::Protocol::https module is installed. ]

#!"\xampp\perl\bin\perl.exe"
use strict;
use warnings;
use LWP::UserAgent;
print   "Content-Type: text/html\n\n";
my $ua = LWP::UserAgent->new(ssl_opts => { verify_hostname => 1 });
my $res = $ua->get("https://news.ycombinator.com/item\?id=25614167");
print "[".$res."]";
print "[".$res->decoded_content."]";

I've got "LWP::Protocol::https" installed. "cpanm LWP::Protocol::https" returns "LWP::Protocol::https is up to date. (6.10)"

I've tried writing the above in a host of different ways and pointing at different HTTPS sites; it works on HTTP sites, i have "Net::SSL" installed ("Crypt::SSLeay" is up to date. (0.72)), no firewalls, reinstalled the latest XAMPP server, installed the latest Strawberry Perl in place of the XAMPP one, just run out of ideas, any suggestions welcome.

edit; The shebang line actually points to Strawberry Perl portable, i replaced the XAMPP Perl folder with this so i didn't need to change the shebang line in all my scripts. -but I've also tried this using XAMPPs perl, with same results.

Edit2; since I'm getting warning on this site about answering comments, I'll answer here and clear my replies.

@TLP, $^X was "D:\xampp\perl\bin\perl.exe" installed new non-portable, changed shebang and $^X is now "C:\Strawberry\perl\bin\perl.exe" but with same results as above. httpd-perl.conf isn't a file in my installation, anyway isn't this upstream of the problem, its running Perl, its Perl that isn't properly running its modules..?

@stevieb, perl 5, version 32, subversion 0 (v5.32.0) built for MSWin32-x86-multi-thread-64int

@Steffen Ullrich, not sure how to use "perl -MLWP::Protocol::https -e ''", but after some research i used eval(); to test if module exists, "LWP::UserAgent" does, but "LWP::Protocol::https" doesn't, even though "cpanm LWP::Protocol::https" in cmd returns "LWP::Protocol::https is up to date. (6.10)". Same with IO::Socket::SSL and Net::SSLeay. So this is the problem, not sure now to solve it.

@TLP, "perldoc -l LWP::Protocol::https" returns "C:\Strawberry\perl\site\lib\LWP\Protocol\https.pm", which exists and is v6.10. "print @INC;" lists; "C:\Strawberry\perl\bin\perl.exe C:/Strawberry/perl/site/lib C:/Strawberry/perl/vendor/lib C:/Strawberry/perl/lib". So it should be finding it in "C:/Strawberry/perl/site/lib"..?

1
You are not using the Strawberry perl binary, you are using the xmapp perl binary, as shown in your shebang. - TLP
...so you need to use the cpan that came with xampp (or the get cpanm to use that perl) - ikegami
Or conversely, you could have your script use your SP instead of your xampp's Perl. - ikegami
@jobeSW The shebang might not be relevant. Try printing the $^X executable name to see which one is being used. - TLP
Try to a actually load the file, i.e. perl -MLWP::Protocol::https -e ''. It might be that dependencies are missing. And note that you should better use Net::SSLeay + IO::Socket::SSL, not Crypt::SSLeay. See also DO YOU NEED Crypt::SSLeay? in the documentation of Crypt::SSLeay about this. - Steffen Ullrich

1 Answers

0
votes

Thanks for all your suggestions, i actually learned a lot here today.

But in the end, the solution was to re-install XAMPP on D: and point the shebang to an msi installed Strawberry Perl on C:. No other combination would work for me.

I haven't really gotten to the bottom of whats happened, but this solution will let me continue with my project.