POE::Session->create ( inline_states => { _start => sub { my ( $kernel, $heap ) = @_[ KERNEL, HEAP ]; # Post a request to the HTTP user agent component. When the # component has an answer (positive or negative), it will # send back a "got_response" event with an HTTP::Response # object. $heap->{www_time_start} = [gettimeofday]; $kernel->post( "BY-ua" => request => got_response => GET $url ); $self->queue_stats("enqueue", $url); }, # A response has arrived. Display it. got_response => sub { my ( $heap, $request_packet, $response_packet ) = @_[ HEAP, ARG0, ARG1 ]; my $http_request = $request_packet->[0]; my $http_response = $response_packet->[0]; my $iv = tv_interval ($heap->{www_time_start}); my $url_iv = sprintf "%s=%.2f", substr($http_request->url(), -10), $iv; DEBUG "Response time: $iv"; # Make the response presentable, and display it. DEBUG "Received result for ", $http_request->url(), ": ", $http_response->as_string(); }, );