Timeout for LWP request

2019-09-09 15:54发布

I'm creating a user agent using LWP::UserAgent. I want to timeout $ua->request(). how can I do that?

my $ua = LWP::UserAgent->new();
my $request = HTTP::Request->new(DELETE => $url);
$req->authorization_basic($user, $pwd);
my $response = $ua->request($req);

I know LWP has time out, but according to the documentation

The requests is aborted if no activity on the connection to the server is observed for timeout seconds. This means that the time it takes for the complete transaction and the request() method to actually return might be longer.

0条回答
登录 后发表回答