I am trying to interact with webserver. It’s a simple Get and Post kind of request response methods implemented at the server. All I wanted to do is use HTTP1.1 Post x2 times as shown below:
POST http://someip:port/ HTTP/1.1 User-Agent: Perlprogram/0.1 Host: someip:port Accept: application/text Content-Type: application/text Content-Length: xxx UserID: Username, Password: password HTTP/1.1 200 OK Date: Mon, 15 Dec 2008 20:49:26 CST Cache-Control: no-store Content-Type: application/text Content-Length: xxx Login Successful POST http://someip:port/ HTTP/1.1 User-Agent: Perlprogram/0.1 Host: someip:port Accept: application/text Content-Type: application/text Content-Length: xxx Send some conf file HTTP/1.1 200 OK Date: Mon, 15 Dec 2008 20:49:27 CST Cache-Control: no-store Content-Type: application/text Content-Length: xxx Here it is........
I tried using Socket/HTTP:NET/LWP etc with no success. Below is my example code.
#!/usr/bin/perl -w use strict; use LWP::UserAgent; use HTTP::Request::Common; my $message; my $userAgent = LWP::UserAgent->new(agent => 'Perlprogram/0.1'); $message = "UserID: Username, Password: password"; my $response = $userAgent->request(POST 'http://someip:port/', Content_Type => 'application/text', Connection => 'Keep-alive', Content => $message); if ($response->is_success) { print $response->content; } else { print $response->status_line, "\n"; }
I tried to insert another post code in or run them in different get post .pl files yield no help. Because server sees connection closed due to post close response.
POST / HTTP/1.1 TE: deflate,gzip;q=0.3 Connection: Keep-alive, TE, close Host: someip:port User-Agent: Perlprogram/0.1 Content-Length: xxx Content-Type: application/text
I see something like above in the wireshark which means my connection is TE,Close by some reason. So after webserver's response my connection and login becomes invalid. Due to this I am unable to retrive file with second post. Second observation I made was in the TCP header my sequence number starts with 1 instead of continuation. E.g.: my client program should say Next Sequence number will be: 343 and it should go to that sequence number and send post message so that webserver can reply. Any help will be appreciated.

In reply to HTTP Post read response , Post again by perljunkie

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.