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

I have been able to get this script working perfect with one site I am trying to login and post to, but I get this error on this domain just with the login. What I see happening is the login is posting to a "http" page and then in process is being redirected to a "https" page. This is the error that I get:

501 (Not Implemented) Protocol scheme 'https' is not supported Client- +Date: Fri, 24 May 2002 16:56:33 GMT
So, if the problem is the redirect to an https, how do I resolve that? Here is my script:

#!/usr/lib/perl use strict; use warnings; use LWP::UserAgent; use HTTP::Request::Common; use HTTP::Cookies; use LWP::Simple; #need to get sessionid so it is nice and new my $page = get 'http://www.sitedomain.com/Login.jsp'; $page =~ /jid=(\w+)/; my $jid = $1; my $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies->new(file => 'cookie_jar', autosave =>1) +); push @{ $ua->requests_redirectable }, 'POST'; my $request = $ua->request(POST "http://www.sitedomain.com/Login.jsp", { username => 'abc123', password => '123abc', 'Submit' => 'Sign in', }); print $request->is_success ? "worked\n" : "failed\n"; print $b = $request->as_string;

THANKS a ton!

Michael Jensen
michael at inshift.com
http://www.inshift.com

Replies are listed 'Best First'.
(wil) Re: LWP- post to HTTP then redirects to HTTPS (501 error)
by wil (Priest) on May 24, 2002 at 18:19 UTC
    LWP::UserAgent on it's own can not interact with secure servers. You need to use Crypt::SSLeay which is available from CPAN.

    Crypt::SSLeay provides support for the https protocol under LWP, so that a LWP::UserAgent can make https GET & HEAD & POST requests.

    From what I remember, you will also need to have either OpenSSL or SSLeay installed locally before you try and isntall Crypt::SSLeay.

    - wil
      wil: you are great! that did it! isn't LWP amazing?

      Michael Jensen
      michael at inshift.com
      http://www.inshift.com