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

In reply to LWP- post to HTTP then redirects to HTTPS (501 error) by inblosam

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.