diff -Naur old/lib/WebService/HIBP.pm new/lib/WebService/HIBP.pm
--- old/lib/WebService/HIBP.pm 2019-02-17 20:58:15.000000000 +1100
+++ new/lib/WebService/HIBP.pm 2019-03-19 19:33:02.090062356 +1100
@@ -9,18 +9,23 @@
use WebService::HIBP::Breach();
use WebService::HIBP::Paste();
-our $VERSION = '0.08';
+our $VERSION = '0.09';
sub _LENGTH_OF_PASSWORD_PREFIX { return 5; }
sub new {
- my ($class) = @_;
+ my ( $class, %params ) = @_;
my $self = {};
bless $self, $class;
$self->{url} = '
https://haveibeenpwned.com/api/v2/';
$self->{password_url} = '
https://api.pwnedpasswords.com/range/';
- $self->{ua} = LWP::UserAgent->new( agent => 'WebService-HIBP' );
- $self->{ua}->env_proxy();
+ if ( $params{user_agent} ) {
+ $self->{ua} = $params{user_agent};
+ }
+ else {
+ $self->{ua} = LWP::UserAgent->new( agent => 'WebService-HIBP' );
+ $self->{ua}->env_proxy();
+ }
return $self;
}
@@ -204,7 +209,13 @@
=head2 new
-a new C<WebService::HIBP> object, ready to check how bad the pwnage is.
+a new C<WebService::HIBP> object, ready to check how bad the pwnage is. It accepts an optional hash as a parameter. Allowed keys are below;
+
+=over 4
+
+=item * user_agent - A pre-configured instance of L<LWP::UserAgent|LWP::UserAgent> that will be used instead of the automatically created one. This allows full control of the user agent properties if desired
+
+=back
=head2 password
diff -Naur old/t/01-hibp.t new/t/01-hibp.t
--- old/t/01-hibp.t 2019-02-17 20:51:17.000000000 +1100
+++ new/t/01-hibp.t 2019-03-19 19:31:17.527794579 +1100
@@ -384,5 +384,6 @@
ok($@, "account threw an error when supplied a bad proxy:$@");
}
+$hibp = WebService::HIBP->new(user_agent => LWP::UserAgent->new());
done_testing();