One of kind Internal Server Error after Post to a secure site
One of kind Internal Server Error after Post to a secure site
am 19.01.2007 14:01:34 von John.Meagher
Hi All,
I've done my best to figure this out but I've reached a point where I
don't even know where to look for answers. I am using Mechanize and
SSLeay to connect to a secure site. After I make the connection (which
works) I try to login to the site. When I post I get an error back from
the server saying it had a vb script mismatch error. It sounds to me
like it's looking for one kind of variable and I'm passing the wrong
one. Below I have my simple code, some debug, and the server error. If
anyone could just point me in some kind of direction on what to do or
where to look for answers I would realllllly appreciate it. I've been
trying to get this to work for about a week and a half now...... In the
end all's I need to do is logon to the site and download and excel file.
I tried this first in vb script but course that's crap with the
sendkeys. Wont work with the secure screensaver on. Knowing some Perl
from a while ago I knew it must have a solution.
=20
**********************code********************************** *
#!/usr/bin/perl
=20
=20
use warnings;
use strict;
use Crypt::SSLeay;
use WWW::Mechanize;
use CGI;
=20
=20
my $cgi =3D CGI->new();
my $form =3D $cgi->Vars;
=20
my $agent =3D WWW::Mechanize->new();
$agent->cookie_jar(HTTP::Cookies->new());
=20
my $login =3D "user";
my $pass =3D "pw";
use LWP::Debug qw(+);
$agent->agent_alias( 'Windows IE 6' );
=20
$ENV{HTTPS_PROXY} =3D 'my.proxy.com';
=20
$agent->get('https://www.somehttpssite.com/webnews/login.asp ');
=20
$agent->submit_form(=20
form_number =3D> 1,=20
fields =3D> { userID =3D> $login, password =3D> $pass =
},=20
);=20
=20
$agent->follow ( 'logout' );=20
$agent->click(); =20
=20
print "Content-type: text/plain\n\n";
print $agent->content();
=20
**********************debug********************************* **
LWP::UserAgent::new: ()
LWP::UserAgent::proxy: http my.proxy.com
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.somehttpssite.com for
cookies
HTTP::Cookies::add_cookie_header: Checking .nittsu.com for cookies
HTTP::Cookies::add_cookie_header: Checking nittsu.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: GET
https://www.somehttpssite.com/webnews/login.asp
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 780 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 139 bytes
HTTP::Cookies::extract_cookies: Set cookie ASPSESSIONIDCCTTBQRT =3D>
CAJPIIEAJMDEH
KLHNEKCKGBE
LWP::UserAgent::request: Simple response: OK
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.somehttpssite.com for
cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=3D/
HTTP::Cookies::add_cookie_header: - checking cookie
ASPSESSIONIDCCTTBQRT=3DCAJPII
EAJMDEHKLHNEKCKGBE
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: Checking .nittsu.com for cookies
HTTP::Cookies::add_cookie_header: Checking nittsu.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: POST
https://www.somehttpssite.com/webnews/login.asp
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 788 bytes
LWP::Protocol::collect: read 741 bytes
LWP::UserAgent::request: Simple response: Internal Server Error
Content-type: text/plain
**********************error********************************* **
Nippon Express USA, Inc: Microsoft VBScript runtime
Error
Server Error in '/webnews' Application.
color=3D'silv
er'>
Microsoft VBScript runtime Error
Description: Type mismatch: 'Cint' (0x800A000D)
Source File: /webnews/usercheck.asp
Line: 31
Version Information: Microsoft-IIS/6.0, CGI/1.1
Nippon Express USA, Inc.
Please notify your Nippon Express
tech su
pport personnel or your representative in regards to this error.
RE: One of kind Internal Server Error after Post to a secure site
am 19.01.2007 14:44:36 von ted.behling
Perhaps your server-side app is expecting a cookie or other parameter
that's missing? You might want to look again at how this Web app acts
in an actual browser, so you can simulate that more closely in your
script. I often use Firefox's "Tamper Data" plugin for this, which
works like a charm. "LiveHTTPHeaders" is good also.
Ted Behling
Hargray Communications
-----Original Message-----
From: Meagher, John T [mailto:John.Meagher@xerox.com]=20
Sent: Friday, January 19, 2007 8:02 AM
To: libwww@perl.org
Subject: One of kind Internal Server Error after Post to a secure site
Hi All,
I've done my best to figure this out but I've reached a point where I
don't even know where to look for answers. I am using Mechanize and
SSLeay to connect to a secure site. After I make the connection (which
works) I try to login to the site. When I post I get an error back from
the server saying it had a vb script mismatch error. It sounds to me
like it's looking for one kind of variable and I'm passing the wrong
one. Below I have my simple code, some debug, and the server error. If
anyone could just point me in some kind of direction on what to do or
where to look for answers I would realllllly appreciate it. I've been
trying to get this to work for about a week and a half now...... In the
end all's I need to do is logon to the site and download and excel file.
I tried this first in vb script but course that's crap with the
sendkeys. Wont work with the secure screensaver on. Knowing some Perl
from a while ago I knew it must have a solution.
=20
**********************code********************************** *
#!/usr/bin/perl
=20
=20
use warnings;
use strict;
use Crypt::SSLeay;
use WWW::Mechanize;
use CGI;
=20
=20
my $cgi =3D CGI->new();
my $form =3D $cgi->Vars;
=20
my $agent =3D WWW::Mechanize->new();
$agent->cookie_jar(HTTP::Cookies->new());
=20
my $login =3D "user";
my $pass =3D "pw";
use LWP::Debug qw(+);
$agent->agent_alias( 'Windows IE 6' );
=20
$ENV{HTTPS_PROXY} =3D 'my.proxy.com';
=20
$agent->get('https://www.somehttpssite.com/webnews/login.asp ');
=20
$agent->submit_form(=20
form_number =3D> 1,=20
fields =3D> { userID =3D> $login, password =3D> $pass =
},=20
);=20
=20
$agent->follow ( 'logout' );=20
$agent->click(); =20
=20
print "Content-type: text/plain\n\n";
print $agent->content();
=20
**********************debug********************************* **
LWP::UserAgent::new: ()
LWP::UserAgent::proxy: http my.proxy.com
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.somehttpssite.com for
cookies
HTTP::Cookies::add_cookie_header: Checking .nittsu.com for cookies
HTTP::Cookies::add_cookie_header: Checking nittsu.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: GET
https://www.somehttpssite.com/webnews/login.asp
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 780 bytes
LWP::Protocol::collect: read 4096 bytes
LWP::Protocol::collect: read 139 bytes
HTTP::Cookies::extract_cookies: Set cookie ASPSESSIONIDCCTTBQRT =3D>
CAJPIIEAJMDEH KLHNEKCKGBE
LWP::UserAgent::request: Simple response: OK
LWP::UserAgent::request: ()
HTTP::Cookies::add_cookie_header: Checking www.somehttpssite.com for
cookies
HTTP::Cookies::add_cookie_header: - checking cookie path=3D/
HTTP::Cookies::add_cookie_header: - checking cookie
ASPSESSIONIDCCTTBQRT=3DCAJPII EAJMDEHKLHNEKCKGBE
HTTP::Cookies::add_cookie_header: it's a match
HTTP::Cookies::add_cookie_header: Checking .nittsu.com for cookies
HTTP::Cookies::add_cookie_header: Checking nittsu.com for cookies
HTTP::Cookies::add_cookie_header: Checking .com for cookies
LWP::UserAgent::send_request: POST
https://www.somehttpssite.com/webnews/login.asp
LWP::UserAgent::_need_proxy: Not proxied
LWP::Protocol::http::request: ()
LWP::Protocol::collect: read 788 bytes
LWP::Protocol::collect: read 741 bytes
LWP::UserAgent::request: Simple response: Internal Server Error
Content-type: text/plain
**********************error********************************* **
Nippon Express USA, Inc: Microsoft VBScript runtime
Error
Server Error in '/webnews' Application.
color=3D'silv
er'>
Microsoft VBScript runtime Error
Description: Type mismatch: 'Cint' (0x800A000D)
Source File: /webnews/usercheck.asp Line: 31
Version Information: Microsoft-IIS/6.0, CGI/1.1
Nippon Express =
USA, Inc.
Please notify your Nippon Express tech su pport personnel or
your representative in regards to this error.
RE: One of kind Internal Server Error after Post to a secure site
am 19.01.2007 16:59:56 von John.Meagher
=20
Ted and Mark,
Thank you very much for your replies. Well I figured out I'm an idiot.
There was some hidden fields in the form that I was ignoring. I knew
they were there but when I looked at the javascript it had to do with
what kind of browser the user might have. So of course I just forgot
about it. After downloading firefox I was looking at the "page info"
and it showed integers as values in the hidden fields. It all came
together then because the server error was "mismatch Cint". I wasn't
passing the hidden fields... That one hurt.
Anyway I'm on to the next problem in that the windows security warning
window pops up when I try to download the file. I would think that
Mechanize wouldn't be able to handle that because it's outside the
object.
Thanks again
John
RE: One of kind Internal Server Error after Post to a secure site
am 19.01.2007 17:04:20 von ted.behling
Windows security window? I can't imagine why that would happen, based
on the code you shared previously. Maybe there's some firewall software
on the machine?
-----Original Message-----
From: Meagher, John T [mailto:John.Meagher@xerox.com]=20
Sent: Friday, January 19, 2007 11:00 AM
To: libwww@perl.org
Subject: RE: One of kind Internal Server Error after Post to a secure
site
=20
Ted and Mark,
Thank you very much for your replies. Well I figured out I'm an idiot.
There was some hidden fields in the form that I was ignoring. I knew
they were there but when I looked at the javascript it had to do with
what kind of browser the user might have. So of course I just forgot
about it. After downloading firefox I was looking at the "page info"
and it showed integers as values in the hidden fields. It all came
together then because the server error was "mismatch Cint". I wasn't
passing the hidden fields... That one hurt.
Anyway I'm on to the next problem in that the windows security warning
window pops up when I try to download the file. I would think that
Mechanize wouldn't be able to handle that because it's outside the
object.
Thanks again
John
RE: One of kind Internal Server Error after Post to a secure site
am 19.01.2007 18:01:09 von John.Meagher
Sorry Ted I never seem to explain myself well. I was just talking about
what happens when I manually retrieve the file with IE. I tried to do
it manually with firefox to see if I get the security warning message
(this just asks if you want to open, save, or cancel) but it doesn't
like one of the sites javascript buttons. I guess my question is how to
handle a file once I use click() or submit() with Mechanize. This might
be obvious to a vet Perl programmer but like I said it's been a long
time for me. Do I have to associate a file handle to click() or
submit() or am I just grasping :) - if you want to slap me and tell me
to go back to Perl beginners school I understand.=20
Windows security window? I can't imagine why that would happen, based
on the code you shared previously. Maybe there's some firewall software
on the machine?