Skip to content

Commit

Permalink
user ua must support 'get' and 'post'
Browse files Browse the repository at this point in the history
  • Loading branch information
mickeyn committed Aug 5, 2016
1 parent 35a5537 commit 36e0159
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/MetaCPAN/Client/Request.pm
Expand Up @@ -59,13 +59,19 @@ has _is_agg => (

sub _build_ua {
my $self = shift;

# This level of indirection is so that if a user has not specified a custom UA
# MetaCPAN::Client and ElasticSearch will have their own UA's
#
# But if the user **has** specified a custom UA, that UA is used for both.
if ( $self->_has_user_ua ) {
return $self->_user_ua;
my $ua = $self->_user_ua;
croak "cannot use given ua (must support 'get' and 'post' methods)"
unless $ua->can("get") and $ua->can("post");

return $self->_user_ua;
}

return HTTP::Tiny->new( @{ $self->ua_args } );
}

Expand Down

0 comments on commit 36e0159

Please sign in to comment.