I believe you mean to do two requests on the same connection? Yet you do nothing to tell LWP to do so (assuming it's even capable of doing so).
Yes. HTTP 1.1 Post; read response. If successful; post again with new request. But on the same connection.
If you know TCP you will see in TCP header Source Port, Destination Port, Sequence Number, next sequence number, ack number. For two consutive posts TCP sequence number always starts from 1.
Webserver is: thttpd.
#!/usr/bin/perl -w
use strict;
use LWP::UserAgent;
use HTTP::Request::Common;
#Post 1 for login
my $userAgent = LWP::UserAgent->new(agent => 'Perlprogram/0.1');
my $message = "UserID: Username, Password: passwordr";
my $response = $userAgent->request(POST 'http://someip:port/',
Content_Type => 'application/text',
Connection => 'Keep-alive',
Content => $message);
#print $response->error_as_HTML unless $response->is_success;
#print $response->as_string;
if ($response->is_success) {
print $response->content;
#post again if success
my $userAgent2 = LWP::UserAgent->new(agent => 'Perlprogram/0.1');
my $message2 = "GetParam";
my $response2 = $userAgent2->request(POST 'http://someip:port/',
Content_Type => 'application/text',
Connection => 'Keep-alive',
Content => $message2);
print $response2->error_as_HTML unless $response2->is_success;
print $response2->as_string;
}
else {
print $response->status_line, "\n";
}
I see in some new response my Keep-alive syntext was not proper. Let me modify and will post you result. Thanks for replies guys.....
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.