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

# sucked this right out of news. Is there one or two # simple edits to pick up https? All we want to do # is check that a page is responding. # Tried to replace with https: but boom. Thanks use strict; use LWP::UserAgent; use HTTP::Request; use HTTP::Response; my $ua = new LWP::UserAgent; my $res = new HTTP::Response; #my $req = new HTTP::Request 'GET' => "http://www.yahoo.com"; $res = $ua->request($req); print $res->code; open MYRESFILE, ">result.txt" or die; print MYRESFILE $res->as_string; close MYRESFILE;

Replies are listed 'Best First'.
Re: Checking that a page gets served via HTTPS
by geekgrrl (Pilgrim) on Apr 29, 2004 at 20:14 UTC

    I'm a fan of WWW::Mechanize. Below is an example. the cookie jar is not always needed of course.

    use strict;
    use WWW::Mechanize;
    use Data::Dumper;
    use HTTP::Cookies; 
    
    my $server_name = "https://flutest.lanl.gov";
    
    my $mech = WWW::Mechanize->new();
    $mech->cookie_jar(HTTP::Cookies->new);
    
    warn "testing on $server_name";
    
    my $results = $mech->get($server_name);
    #warn Dumper $results;
    
    if($results->content =~ /please enter your login and password to authenticate/)
      {
        print "site is up";
      }
    else
      {
        warn Dumper $results;
        die "site is down!!!";
      }
    
Re: Checking that a page gets served via HTTPS
by kutsu (Priest) on Apr 29, 2004 at 17:40 UTC

    Look at the head function of Getting more out of LWP::Simple

    "Cogito cogito ergo cogito sum - I think that I think, therefore I think that I am." Ambrose Bierce