package tt;
use strict;
use HTTP::Cookies;
use HTML::Form;
use HTTP::Request::Common qw(GET POST);
use POE qw(Component::Client::HTTP);
use POE::Component::Client::Keepalive;
my $pool = POE::Component::Client::Keepalive->new(
keep_alive => 2, # seconds to keep connections alive
max_open => 500, # max concurrent connections - total
max_per_host => 20, # max concurrent connections - per host
timeout => 300, # max time (seconds) to establish a new connection
);
POE::Component::Client::HTTP->spawn (
Agent => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows 98)',
Alias => 'uaa',
Timeout => 300,
FollowRedirects => 3,
ConnectionManager => $pool,
);
POE::Session->create(
package_states => [ "tt" => [ "_start", "got_response", "_stop" ] ]
);
$poe_kernel->run();
sub got_response {
my ( $heap, $request_packet, $response_packet, $kernel ) = @_[ HEAP, ARG0, ARG1, KERNEL ];
my $http_request = $request_packet->[0];
my $subject = $request_packet->[1][0];
my $http_response = $response_packet->[0];
print $http_response->as_string;
}
sub _start {
my ( $kernel, $heap ) = @_[ KERNEL, HEAP ];
my $session = $kernel->get_active_session();
my $request = { "title" => [ "CHRIS", ],
"action" => POST( "
http://www.chriselectronics.com/inventory.cfm",
[ "whatToSearch" => 1,
"searchCriteria" => 'NRC04F1212TR',
],
),
};
$kernel->post( 'uaa', 'request', 'got_response', $request->{action}, $request->{title} );
}
sub _stop {
print "Stop\n";
}