From: Marius Gavrilescu Date: Sat, 6 Jun 2015 19:32:14 +0000 (+0300) Subject: Do not depend on LWP X-Git-Tag: 0.001~3 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=8ab946797f4be531660d36da4f8813b22526b9b8;p=www-backpacktf.git Do not depend on LWP --- diff --git a/Makefile.PL b/Makefile.PL index 6d4a2b7..d08e328 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -11,11 +11,10 @@ WriteMakefile( SIGN => 1, PREREQ_PM => { qw/JSON::MaybeXS 0 - LWP::Simple 0 PerlX::Maybe 0/, }, BUILD_REQUIRES => { - qw/LWP::Online 0/, + qw/Test::RequiresInternet 0/, }, META_MERGE => { dynamic_config => 0, diff --git a/README b/README index 01b8a59..9483b54 100644 --- a/README +++ b/README @@ -19,7 +19,6 @@ DEPENDENCIES This module requires these other modules and libraries: * JSON -* LWP COPYRIGHT AND LICENCE diff --git a/lib/WWW/BackpackTF.pm b/lib/WWW/BackpackTF.pm index 015d9fa..7f485d6 100644 --- a/lib/WWW/BackpackTF.pm +++ b/lib/WWW/BackpackTF.pm @@ -23,18 +23,22 @@ BEGIN { } use JSON::MaybeXS qw/decode_json/; -use LWP::Simple qw/get/; +use HTTP::Tiny; use PerlX::Maybe; use WWW::BackpackTF::Currency; use WWW::BackpackTF::Item; use WWW::BackpackTF::User; +my $ht = HTTP::Tiny->new(agent => "WWW-BackpackTF/$VERSION"); + sub request { my ($self, $url, %params) = @_; $params{key} = $self->{key} if $self->{key}; $url = $self->{base} . $url; $url .= "&$_=$params{$_}" for keys %params; - my $response = decode_json(get $url)->{response}; + my $htr = $ht->get($url); + die $htr->{reason} unless $htr->{success}; + my $response = decode_json($htr->{content})->{response}; die $response->{message} unless $response->{success}; $response } diff --git a/t/50-network.t b/t/50-network.t index 3f58417..8f37da4 100644 --- a/t/50-network.t +++ b/t/50-network.t @@ -2,7 +2,7 @@ use strict; use warnings; -use LWP::Online ':skip_all'; +use Test::RequiresInternet 'backpack.tf' => 80; use Test::More tests => 6; use WWW::BackpackTF;