HTTP::Request help (Getting past ASP Login pages) 
Author Message
 HTTP::Request help (Getting past ASP Login pages)

Hello,

First posting here, hoping anyone can assist me here.

I'm trying to post some info to a form at /check/check.asp, but I get
redirected to a /login.asp script whenever I send the request. I'm
suspecting it's asking me to log in first, that's my problem.

I've tried sending the login info along with the main request to check.asp,
to no avail. I've tried sending the login info first to /login.asp, then
using the same UserAgent call, post my request to /check/check.asp. The
username and password are valid. What am I doing wrong? Sorry for the mess.

(URLs replaced)

$request1 = "ID=login&password=pass&txt1=you&txt2=me";

$url1 = "/check/Check.asp";     # URL to post to

# set up the HTTP request
my $ua = LWP::UserAgent->new;
my $rq1 = HTTP::Request->new (POST => $url1);
$rq1->header('Content-Type' => 'text/xml');

#####
$url2 = "Login.asp";     # URL to post to (
$request2 = "txtID=login&txtpassword=pass";
my $rq2 = HTTP::Request->new (POST => $url2);
$rq2->header('Content-Type' => 'text/xml');

# Set the content of the request to the XML request text
$rq1->content($request1);
# Set the content of the request to the XML request text
$rq2->content($request2);

$ua->request($rq2);
my $response = $ua->request($rq1);



Mon, 09 Jun 2003 02:42:41 GMT  
 HTTP::Request help (Getting past ASP Login pages)

Quote:

> I'm trying to post some info to a form at /check/check.asp, but I get
> redirected to a /login.asp script whenever I send the request. I'm
> suspecting it's asking me to log in first, that's my problem.

You probably need to simulate submission the form that you find on the
/login.asp page, save the cookie returned and then send a request to
/check/check.asp with the same cookie.  You can automate cookie
handling in LWP::UserAgent simply by saying:

$ua->cookie_jar(HTTP::Cookies->new);

Quote:
> $request1 = "ID=login&password=pass&txt1=you&txt2=me";
> my $rq1 = HTTP::Request->new (POST => $url1);
> $rq1->header('Content-Type' => 'text/xml');
> # Set the content of the request to the XML request text
> $rq1->content($request1);

XML?  XML?!  Do you have any idea what XML looks like?  That
$request1 variable is _not_ XML.  It doesn't look anything like XML.

The correct content type to describe it is
'application/x-www-form-urlencoded'.  (Dunno why there's still an 'x-'
in there after all these years).

Change the content-type and give the user agent a cookie jar and your
code may work.

You should consider using HTTP::Request::Common rather than building
application/x-www-form-urlencoded content by hand.

--
     \\   ( )
  .  _\\__[oo

 .  l___\\
  # ll  l\\
 ###LL  LL\\



Mon, 09 Jun 2003 03:05:13 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. HTTP::Request help (Getting past ASP Login pages)

2. Submitting http request and getting/parsing resulting page?

3. Application Service Provider-http://zjj90:8080/servlet/inchstservlet-fee management page.-asp

4. Application Service Provider-http://zjj90:8080/servlet/inchstservlet-fee management page.-asp

5. Getting data from asp pages

6. HTTP::Headers - getting request headers

7. Apache::ASP: Trouble opening .asp pages

8. HELP with accessing HTML page to automate Login using HTML::Form

9. Need Perl Script for Members Login Page- help

10. Net::Telnet problem getting past password

11. Getting past protected directories?

12. HTTP::Request::Common and HTTP::Cookies

 

 
Powered by phpBB® Forum Software