Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add timeout() attribute to REST client

  • Loading branch information...
commit 4525fd4f32f1902856926f27c012d31e6f1b1a07 1 parent ce592c5
Ray Miller authored
Showing with 14 additions and 5 deletions.
  1. +14 −5 packages/LIMS2-REST-Client/lib/LIMS2/REST/Client.pm
View
19 packages/LIMS2-REST-Client/lib/LIMS2/REST/Client.pm
@@ -48,6 +48,12 @@ has proxy_url => (
coerce => 1
);
+has timeout => (
+ is => 'ro',
+ isa => 'Int',
+ default => 180
+);
+
has ua => (
is => 'ro',
isa => 'LWP::UserAgent',
@@ -57,16 +63,19 @@ has ua => (
sub _build_ua {
my $self = shift;
- # Set proxy
my $ua = LWP::UserAgent->new();
- $ua->proxy( http => $self->proxy_url )
- if defined $self->proxy_url;
+ if ( defined $self->proxy_url ) {
+ $ua->proxy( http => $self->proxy_url );
+ }
- # Set credentials
- if ( $self->username ) {
+ if ( defined $self->username ) {
$ua->credentials( $self->api_url->host_port, $self->realm, $self->username, $self->password );
}
+ if ( defined $self->timeout ) {
+ $ua->timeout( $self->timeout );
+ }
+
return $ua;
}
Please sign in to comment.
Something went wrong with that request. Please try again.