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

There are no requirements about how HTTP requests are put in packets. HTTP works over TCP and only deals with connection streams. Dividing into packets is up to the TCP stack of the operating system.

Applications can influence when packets are sent by flushing buffers. LWP::UserAgent probably does two separate write for the header and the POST body, and the OS sends that as two packets.

Either you or the network sniffer aren't giving the real HTTP header. But it looks like a proper HTTP POST, with the Content-Type, Content-Length, and url encoded body.

Any application that wants to reliabily examine HTTP must be able to reassemble the stream from packets. Depending on clients to send the header and enough of the POST body in the same packets is unreliable.

Replies are listed 'Best First'.
Re: Re: HTTP::Request(POST, ...)
by Anonymous Monk on Jun 01, 2004 at 17:48 UTC
    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

      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