in reply to Re^2: Error 500 in LWP
in thread Error 500 in LWP

When I make the same 2 changes which you make (https to http and head to get) then all my tests pass. If you are unable to make an HTTP connection to http://microsoft.com/ then that has to be a question for your local network administrator.

Replies are listed 'Best First'.
Re^4: Error 500 in LWP
by YarNik (Sexton) on Aug 17, 2017 at 12:54 UTC
    Thanks for all, I am go to the administrator ;)
Re^4: Error 500 in LWP
by YarNik (Sexton) on Aug 18, 2017 at 09:31 UTC
    With the local network all right, the command is executed and save file. But script LWP with error, there dump:
    # perl ssl.pl $VAR1 = bless( { '_content' => '500 Can\'t connect to www.microsoft.c +om:443 (connect: Network is unreachable) ', '_rc' => 500, '_headers' => bless( { 'client-warning' => 'Internal + response', 'client-date' => 'Fri, 18 Aug + 2017 08:51:50 GMT', 'content-type' => 'text/plain +' }, 'HTTP::Headers' ), '_msg' => 'Can\'t connect to www.microsoft.com:443 ( +connect: Network is unreachable)', '_request' => bless( { '_content' => '', '_uri' => bless( do{\(my $o = + 'https://www.microsoft.com/uk-ua/')}, 'URI::https' ), '_headers' => bless( { 'user-agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit +/537.36 (KHTML, like Gecko) Chrome/60.0.3112.90 Safari/537.36' }, 'HTTP +::Headers' ), '_method' => 'GET' }, 'HTTP::Request' ) }, 'HTTP::Response' );
      https://www.microsoft.com/uk-ua/

      So, I see you have changed the target URL again. I wonder why. Anyway, here, on CentOS 6 is the script which works absolutely perfectly for me:

      use strict; use warnings; use Test::More tests => 1; use LWP::UserAgent; use Data::Dumper; my $ua = LWP::UserAgent->new; my $res = $ua->get ('https://www.microsoft.com/uk-ua/'); is ($res->code, 200, 'Download succeeded'); diag (qq# LWP: $LWP::VERSION IO::Socket::SSL: $IO::Socket::SSL::VERSION#);

      Which gives:

      $ perl sslms.pl 1..1 ok 1 - Download succeeded # # LWP: 5.833 # IO::Socket::SSL: 1.31
        Yes, I changed a little, because I'm looking for a working code.

        Here is a new code where Google returns a different code.

        use strict; use warnings; use LWP::UserAgent; my @hostnames = ( 'http://google.com', 'https://google.com', 'http://microsoft.com', 'https://microsoft.com', 'http://bing.com', 'https://bing.com', ); my $ua = LWP::UserAgent->new; for my $host (@hostnames) { my $res = $ua->get ($host); print $res->code . ' => ' . $res->status_line . "\n"; } print "LWP: $LWP::VERSION\n"; print "IO::Socket::SSL: $IO::Socket::SSL::VERSION\n";
        It returns:
        200 => 200 OK 500 => 500 Can't connect to google.com:443 (connect: Network is unreac +hable) 500 => 500 Can't connect to www.microsoft.com:443 (connect: Network is + unreachable) 500 => 500 Can't connect to www.microsoft.com:443 (connect: Network is + unreachable) 200 => 200 OK 200 => 200 OK LWP: 5.833 IO::Socket::SSL: 1.31