In article <hNOmc.29402$U75.15715edtnps89>,
[email]Zorbanonexistent.com[/email] <nospamnonexistent.com> wrote:
>I am trying to write a script that is authenticated over https, get a cookie
>and accept the redirect 302 from the server to another page.
>
>Can't locate object method "url" via package "URI::https" at
>C:/Perl/site/lib/HTTP/Cookies.pm line 43. Even if I am using Active Perl
>(revision 5 version 8 subversion 3) on Linux version I get similar errors on
>107 line in Cookies.pm module.
>
>#!/usr/bin/perl
>use strict;
>#use warnings;
>use LWP::UserAgent;
>use HTTP::Cookies;
>use HTTP::Headers;
>my $code; my $msg;my $header; my $content;
>my $ua = LWP::UserAgent->new;
>$ua->agent('Mozilla');
>my $cookie_jar = HTTP::Cookies->new(
>file => "$ENV{HOMEPATH}/lwp_cookies.dat",
>autosave => 1,
>);
>my $req = HTTP::Request->new(POST => 'https://cntcaftqa/main/default.asp');
>$req->content_type('application/x-www-form-urlencoded');
>$req->content('userid=myuser&password=mypassword&action =Log+On&url=https://c
>ntcaftqa/main/default.asp');
>my $res = $ua->request($req);
>$cookie_jar->extract_cookies($res);
>if ($res->status_line=='302 Object moved'){
> my $req1 = $res->base;
> $cookie_jar->add_cookie_header($req1);
> $req->content($req1);
> my $res = $ua->request($req);
> print $res->code;
>}
>
I'm not sure what the problem is but you may want to
add debug, and a few print's may help:

use LWP::Debug qw(+);

print $req->as_string;
print $cookie_jar->as_string;
etc.


Also, I'd rewrite this line:
if ($res->status_line=='302 Object moved'){
to:
if ($res->code == 302){


(review perlop for eq/== diff's)

hth,
--
Charles DeRykus