my
$s
= TestServer->new();
my
$url_root
=
$s
->started_ok(
"starting a test server"
);
my
$q
= HTTP::Async->new;
is
$q
->timeout, 180,
"\$q->timeout == 180"
;
{
my
$url
=
"$url_root?delay=0"
;
my
$req
= HTTP::Request->new(
'GET'
,
$url
);
ok
$q
->add(
$req
),
"Added request to the queue - $url"
;
my
$res
=
$q
->wait_for_next_response;
is
$res
->code, 200,
"Not timed out (200)"
;
}
is
$q
->timeout(2), 2,
"Set the timeout really low"
;
{
my
$url
=
"$url_root?delay=3"
;
my
$req
= HTTP::Request->new(
'GET'
,
$url
);
ok
$q
->add(
$req
),
"Added delayed request to the queue - $url"
;
my
$res
=
$q
->wait_for_next_response;
is
$res
->code, 504,
"timed out (504)"
;
ok
$res
->is_error,
"is an error"
;
}
{
my
$url
=
"$url_root?trickle=4"
;
my
$req
= HTTP::Request->new(
'GET'
,
$url
);
ok
$q
->add(
$req
),
"Added trickle request to the queue - $url"
;
my
$res
=
$q
->wait_for_next_response;
is
$res
->code, 200,
"response ok (200)"
;
ok !
$res
->is_error,
"is not an error"
;
}
is
$q
->timeout(1), 1,
"Set the timeout really low"
;
is
$q
->max_request_time(1), 1,
"Set the max_request_time really low"
;
{
my
$url
=
"$url_root?trickle=3"
;
my
$req
= HTTP::Request->new(
'GET'
,
$url
);
ok
$q
->add(
$req
),
"Added trickle request to the queue - $url"
;
my
$res
=
$q
->wait_for_next_response;
is
$res
->code, 504,
"timed out (504)"
;
ok
$res
->is_error,
"is an error"
;
}
is
$q
->timeout(10), 10,
"Lengthen the timeout"
;
is
$q
->max_request_time(300), 300,
"Lengthen the max_request_time"
;
{
my
$url
=
"$url_root?delay=3"
;
my
$req
= HTTP::Request->new(
'GET'
,
$url
);
ok
$q
->add(
$req
),
"Added delayed request to the queue - $url"
;
my
$res
=
$q
->wait_for_next_response;
is
$res
->code, 200,
"Not timed out (200)"
;
}