Skip to content
Browse files

do not fill the undef for cache_arg when WithCache->new(agent => "Web…

…::Scraper")
  • Loading branch information...
1 parent 5273fda commit 6914ebb1efbd52148c12608d704a94cd22624aba @tokuhirom tokuhirom committed Mar 24, 2009
Showing with 8 additions and 1 deletion.
  1. +2 −1 lib/LWP/UserAgent/WithCache.pm
  2. +6 −0 t/01_new.t
View
3 lib/LWP/UserAgent/WithCache.pm
@@ -21,8 +21,9 @@ sub new {
my %lwp_opt;
unless (scalar @_ % 2) {
%lwp_opt = @_;
+ $cache_opt = {};
for my $key (qw(namespace cache_root default_expires_in)) {
- $cache_opt->{$key} = delete $lwp_opt{$key};
+ $cache_opt->{$key} = delete $lwp_opt{$key} if exists $lwp_opt{$key};
}
} else {
$cache_opt = shift || {};
View
6 t/01_new.t
@@ -13,3 +13,9 @@ my $ua = LWP::UserAgent::WithCache->new({namespace => 'other_cache_namespace'},
is $ua->{cache}->get_namespace, 'other_cache_namespace';
is $ua->timeout, 99;
}
+
+{
+my $ua = LWP::UserAgent::WithCache->new(agent => 'Web::Scraper');
+is $ua->{cache}->get_namespace, 'lwp-cache';
+}
+

0 comments on commit 6914ebb

Please sign in to comment.
Something went wrong with that request. Please try again.