I am trying to retrieve a webpage using LWP over an SSL connection. I am getting a 302 error and being returned the page to be redirected to in the header('Location').

The page to be redirected to is a dynamic page and when I try to retrieve it, it is gone as well.

I am using ActiveState Perl 5.6.1 build 626 on Win NT 4.0. I had to install Net::SSLeay by hand from cpan. I have OpenSSL v0.9.6b9 installed.

Any ideas? I have attached the code and output below. I removed the code that tried to retrieve the missing page. Figured it may be better to go from here.
Here is the code
#!/usr/bin/perl -w use strict; use LWP::UserAgent; use LWP::Protocol::https; use URI::URL; my %parm = ( url => 'https://XXX.XXX.XXX.XXX', uatimeout => 120, browser => 'IE/5.0', username => 'XXXXX', password => 'XXXXX', realm => 'XXXXX', ); my $netloc = new URI::URL($parm{'url'})->netloc(); my $ua = new LWP::UserAgent; $ua->agent($parm{'browser'}); $ua->timeout($parm{'timeout'}); $ua->credentials($netloc, $parm{'realm'}, $parm{'username'}, $parm{'password'}); my $request = new HTTP::Request POST=> $parm{'url'}; $request->authorization_basic($parm{'username'}, $parm{'password'}); my $page = $ua->request($request); #print $request->as_string(); if ($page->is_success) { print "Redirect\n"; print $page->content; } elsif ($page->is_redirect) { print $page->content; } else { print $page->error_as_HTML; print $page->content; }
Here is the output
C:\TEMP>perl -w bcbs.pl Redirect <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <HTML><HEAD> <TITLE>302 Found</TITLE> </HEAD><BODY> <H1>Found</H1> The document has moved <A HREF="https://XXX.XXX.XXX.XXX:443/?&amp;STCO +=1O3AEz6wYA2QAACjwXZg&amp;STCOEND">here</A>.<P> <P>Additionally, a 302 Found error was encountered while trying to use an ErrorDocument to handle t +he request . </BODY></HTML>


seanbo

In reply to LWP, SSL, 302 by seanbo

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.