http://qs1969.pair.com?node_id=169935


in reply to Test Availability of HTTPS Web Application?

I'm not sure why you need to 'reverse engineer' legacy Perl code (decipher, maybe ;^), but your right in thinking there's a better way ... well, simpler anyway.

#!/usr/bin/perl -w use strict; use LWP::UserAgent; use HTTP::Request::Common qw/ GET /; my $url = shift; my $browser = LWP::UserAgent->new; my $response = $browser->request( GET $url ); print $response->code;

Personally, I think $response->is_success would be more beneficial as 200 isn't the only response indicating success, but that's your call...

One caveat, tho:- test against a known good site before anything else ... LWP::UserAgent returns a 500 error instead of undef if you don't have have the modules necessary to talk to SSL (aka https) servers.

    --k.


Replies are listed 'Best First'.
Re: Re: Test Availability of HTTPS Web Application?
by Beau Landeaux (Novice) on May 29, 2002 at 02:57 UTC
    You're correct, "is_success" is MUCH better (I'm catchin' on.) Here's the rub: https, repeat 's'. Beau
      Go to the link mentioned as "required modules", i.e. Crypt::SSLeay: "OpenSSL glue that provides LWP https support"