If it is indeed a login problem. The issue is that the OP is probably not keeping up with cookies.
Since HTTP is a stateless protocol, the server has no concept of a login. The application may have a session concept which is normally tracked with cookies. This is why I suspect the problem is cookie related. As I recall, LWP::UserAgent has a feature for using HTTP::Cookies to track a cookie jar that handles this issue.
| [reply] |
Looks like it.
Any sample code to begin with? Will I be able to handle Java Session using IOR?
| [reply] |
require HTTP::Cookies;
my $cookie_jar = HTTP::Cookies->new(
file => 'cookies.txt,
);
$ua->cookie_jar( $cookie_jar );
or default to a temporary in-memory cookie jar with
$ua->cookie_jar( {} );
See HTTP::Cookies and LWP::UserAgent for more details.
| [reply] [d/l] [select] |
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.....
| [reply] [d/l] [select] |