in reply to Re: HTTP::Request(POST, ...)
in thread HTTP::Request(POST, ...)

Burrell, Thanks for your help. Do you know if tere is anyway to leave the HTTP packet not to be splited? How to do flush? From the packets I captured, look like the HTTP packet is not splitted correctly bcause in the 2nd packet, the header of HTTP is not correct. But I don't see any wrongly use of HTTP module. when I send the POST request, I got the error from server" HTTP Status 400 - Invalid direct reference to form login pape" look like the POST resquest is not sent correctly. Do you have any idea? Thanks a lot, Quency

Replies are listed 'Best First'.
Re: Re: Re: HTTP::Request(POST, ...)
by Corion (Patriarch) on Jun 01, 2004 at 17:57 UTC

    When trying to automate any website, always capture what your browser is sending and receiving, and compare that against what you are sending and receiving.

    The error message you are giving, HTTP Status 400 - Invalid direct reference to form login pape, sounds like the server is expecting a valid Referrer: header, and you are not sending any. So, maybe try automating the page through WWW::Mechanize, which tries to behave more like a browser. Once you have that working, you can strip down the script to something only using LWP, or keep the script using WWW::Mechanize.

      Thanks alot, Corion. I use WWW::Mechanize, it makes my life much easy. But I have a problem here: In a page responsed from server, there is a form in which some fields and two buttons are defined like these: --------------------------- <FORM name="frmSaveUser" action='SaveUser" method="post"> ..... <BUTTON class="pbutton" type="button" onclick="validate(document.frmSaveUser)"> Save</BUTTON> <BUTTON class="pbutton" type="button" onclick="history.back()"> Cancel</BUTTON> ....
      </FORM> --------------- I fill fields and call $browser->click_button(number => 1); I got the error: "can't call method "click" on an undefined value at /usr/lib/perl5/site_perl/5.8.0/WWW/Mechanize.pm line 722" On the button defined above, there is a JavaScript funcation defined to check the validation of filled values. Do I do something wrong? or what should I do to make it work? Thanks again Quency

        You will need to understand what the Javascript does, and then program that thing in Perl. There is no Javascript interpreter plus object model for Perl.

        In the documentation of WWW::Mechanize::Shell is some hint as to how you can maybe work around this problem.

        $agent->current_form->push_input( submit => { name => "submit", value +=>"submit" } );

        But most likely, you will have to look at exactly what the Javascript code does. Maybe even $agent->current_form->submit() already works in your case.