I wrote a perl script to send a request to HTTP server using LWP::UserAgent. The code is here:

--------------------------------------------------------
$url = 'http://151.104.234.14/voipadmin/security_chk'; $ua = new LWP::UserAgent; $res = $ua->request(POST $url, Content => [ Submit => 'Submit', user => 'admin', passwd => 'password' ] );
-------------------------------------------------------

When I use the microsoft network monitor to capture the packets, I found that the POST request is not sent correctly. It is sent twice. The 1st sending doesn't include the content (or data ) and the content is sent in the 2nd http request and is not sent as data. Here are the 2 frames I captured:

--------- 1st frame POST request ----------- HTTP: POST Request (from client using port 34746) HTTP: Request Method = POST HTTP: Uniform ResourceIdentifier=/voipadmin/security_chk HTTP: Protocol Version = HTTP/1.1 HTTP: Connection = Keep-Alive HTTP: Host = 151.104.234.14 HTTP: User-Agent = libwww-perl/5.65 HTTP: Content-Length = 35 HTTP: Content-Type = application/x-www-form-urlencoded --------- 2nd frame POST request ----------- HTTP: Submit=Submit&j_username=admin&j_password=password Request (from + client using p HTTP: Request Method = Submit=Submit&user=admin&passwd=password ----------------------------------------------------

Obviously I don't get right response becasue the request is not sent correctly. The request should be sent in one packet, but look like LWP::UserAgent seperates message and send it twice. This is not correct. I check the Max_Size and it is undef (means there is no limit for the packet size). Anyone see this problem before? Any idea about this?

Thanks for your help.
Quency

20040528 Edit by Corion: Added formatting

Edit by BazB: changed all password strings to "password"


In reply to HTTP::Request(POST, ...) by quency

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.