Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

500 error attempting to log in

by dannoura (Pilgrim)
on May 11, 2004 at 15:07 UTC ( #352464=perlquestion: print w/replies, xml ) Need Help??
dannoura has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,

I'm trying to log in to a site using a script. The problem is that I keep getting 500 Can't connect to (connect: Unknown error). The strange thing is that I only get this error when trying sites using authentication (which I guess means this is not a proxy issue). I've tried several with the same result. My code is below. The error is generated immediately after the GET request. As far as I can tell the POST works fine. Does anyone know what could be the problem?

#! c:\perl\bin -w use strict; use LWP::UserAgent; use HTTP::Request::Common; use HTTP::Cookies; use LWP::Debug qw(+); use LWP::Protocol::https; use Crypt::SSLeay; my $ua = LWP::UserAgent->new; $ua->cookie_jar(HTTP::Cookies->new(file => 'cookie_jar', autosave =>1) +); # configure LWP::UserAgent to follow redirects after POST push @{ $ua->requests_redirectable }, 'POST'; my $request=$ua->request( POST "" +, { __VIEWSTATE => 'dDwtMTE1ODc1NzA2NTs7PjAuMSDgHjTB0rV7byCH14/dWkMm', txtUID => 'myID', txtPWD => 'myPass', submit => 'log in' }); print $request->is_success ? $request->content : "failed\n"; $request= $ua->request(GET ""); print $request->is_success ? $request->content : $request->status_line +;


Any comments about coding style are welcome.

Replies are listed 'Best First'.
Re: 500 error attempting to log in
by inman (Curate) on May 11, 2004 at 18:21 UTC
    This node should help you out if you are using https and a proxy. The basic answer is that LWP doesn't work with https and proxy servers. leira posted the work around.
Re: 500 error attempting to log in
by idsfa (Vicar) on May 11, 2004 at 17:16 UTC

    You may want to confirm that your cookies are being properly set in the response from the login page (presumably the reason you set up a cookie jar and post the login). After the initial POST, check out $request->as_string to make sure that you are receiving the expected cookies and then print out $ua->cookie_jar->as_string to confirm that they are getting into your cookie jar. Especially look for headers which expire your cookies immediately.

    If anyone needs me I'll be in the Angry Dome.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://352464]
Approved by Old_Gray_Bear
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2017-12-12 01:19 GMT
Find Nodes?
    Voting Booth?
    What programming language do you hate the most?

    Results (321 votes). Check out past polls.