Hi WorknMan,

"Why does this work in Firefox, but not in $mech" should be a item in the FAQ :-)

Everything the web server knows about the client is present in the HTTP request. If two requests are identical, the results should be identical. So the real question is "What is different between the mech request and the Firefox request?"

I would suggest using the Firefox extension "Tamper Data" to look at the headers of the requests you send to the server. Compare that with what LWP is sending. Once the two are identical, the action of the server should be the same as well.

I say "should", because this is an oversimplification - some values are naturally unique, e.g. a SessionID, but if a SessionID is present, that is probably sufficient, even though the value will be different between the LWP request and the Firefox request. The server could use the session to store information which is troublesome, but that's not the first place to look (and highly unlike to be relevant when you are requesting the login page of your site).

Generally the problem is to be found in missing or incorrect POSTDATA arguments, Cookies, User-Agents, Accepts, etc. If you are using mech, then redirects and cookies should not be a problem, but are listed here for completeness. If you are missing headers, $mech->add_header can be used to add the headers that you need.

Cheers,
Peter

WorknMan wrote:

(Note: I actually posted this message via the Yahoo Groups interface, but then realized that hadn't been updated since 2001. So, assuming this list is still active, this may be a dupe posting - I apologize in advance. This particular problem has been plaguing me for about 4 months. I'm hoping that somebody has a solution.)

I'm trying to hit this URL (corporate intranet):

https://www.dmotorworks.com/ia.ui/broker/login

.... using the following code:

use LWP;
my $URL = "https://www.dmotorworks.com/ia.ui/broker/login";;
my $browser = LWP::UserAgent->new( );
my $response = $browser->get($URL);
print $response->content;

When I go to that URL using Firefox or IE, I get a login screen. When
I try it using LWP, I get a 'servlet exception error'.

I nstalled Crypt::SSLeay (WinXP SP2 and ActivePerl) via the instructions here:
http://johnbokma.com/perl/https.html

I'm able to reach https sites (such as https://www.paypal.com), but
not the one I mentioned above.

Hoping somebody can tell me what I am missing!


Reply via email to