For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > August 2005 > POST request fails









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author POST request fails
jingjing.zhu@gmail.com

2005-08-31, 6:55 pm

Hi,
I was trying to program in Perl to send a POST request to a web
server. The client HTML form is like:

<form name="Form1" method="post" action="report.aspx" id="Form1">
<input type="hidden" name="__EVENTTARGET" value=""/>
<input type="hidden" name="__EVENTTARGUMENT" value=""/>
.....

And I wrote the following Perl script to fill out the __EVENTTARGET
value,

my $ua = LWP::UserAgent->new;
push @ { $ua->requests_redirectable }, 'POST';
$ua->cookie_jar( HTTP::Cookies->new(autosave=>1));
$ua->agent("User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT
5.1; SV1; FunWebProducts")

#....
# Loging process
# a Get request sent to get the form and set cookies in user agent
#.....

$rs = $ua->post( 'https://www.xxxx.com/report.aspx',
[

__EVENTTARGET => 'reports:_ctl3:lnkReport'


],
'Content-Type' =>'application/x-www-form-urlencoded',
'CACHE-CONTROL' =>'NO-CACHE',
':content_file' => 'temp.html');

I expect to get a webpage with report data. Unfortunately, the
webserver returns 200 ok status code but the result page is the same as
the form.

Could anyone see any errors in my script?

Thanks very much,

Jing

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com