5 |
|
# get(url,[location]) : download from the specified url to cache or location |
6 |
|
# return the full url path name incl. any base expansion |
7 |
|
# and the filename downloaded to |
8 |
< |
# setbase(urlstring) : set a base url type |
8 |
> |
# setbase(urlstring) : set a base url type - return the url object |
9 |
|
# unsetbase(type) : deactivate a previously set base |
10 |
|
# currentbase(type) : return the current base for the given type |
11 |
+ |
# expandurl(urlstring) : return the base expanded URLclass of the given string |
12 |
|
# |
13 |
|
# ---------------------------------------------------------------------- |
14 |
|
|
70 |
|
my $type=$url->type(); |
71 |
|
$urltypehandler=$self->_typehandler($type); |
72 |
|
$url->merge($self->currentbase($type)); |
73 |
+ |
#print "Attempting download of ".$url->url()."\n"; |
74 |
|
|
75 |
|
# Generate a location name if not provided |
76 |
< |
$nocache=1; |
76 |
> |
my $nocache=1; |
77 |
|
if ( @_ ) { |
78 |
|
$location=shift; |
79 |
|
$nocache=0; # dont cache if downloaded to an external location |
88 |
|
} |
89 |
|
|
90 |
|
# now register it in the cache if successful |
91 |
< |
if ( $file && $nocache) { |
92 |
< |
$self->{cache}->store($url->url(), $location); |
93 |
< |
} |
94 |
< |
return ($url->url(), $file); |
91 |
> |
if ( $file ne "" ) { |
92 |
> |
if ( $file && $nocache) { |
93 |
> |
#$self->{cache}->store($url->url(), $location); |
94 |
> |
$self->{cache}->store($url->url(), $file); |
95 |
> |
} |
96 |
> |
} |
97 |
> |
return ($url->url(), $file, $urltypehandler->error()); |
98 |
> |
} |
99 |
> |
|
100 |
> |
sub expandurl { |
101 |
> |
my $self=shift; |
102 |
> |
my $urlstring=shift; |
103 |
> |
|
104 |
> |
my $url=URL::URLclass->new($urlstring); |
105 |
> |
my $type=$url->type(); |
106 |
> |
$url->merge($self->currentbase($type)); |
107 |
> |
return $url; |
108 |
|
} |
109 |
|
|
110 |
|
sub setbase { |
116 |
|
$self->checktype($type); |
117 |
|
# make a new base-url object |
118 |
|
push @{$self->{"basestack"}{$type}}, $base; |
119 |
+ |
return $base; |
120 |
|
} |
121 |
|
|
122 |
|
sub unsetbase { |