1 |
williamc |
1.1 |
#
|
2 |
|
|
# standard url interface for local file
|
3 |
|
|
#
|
4 |
|
|
# Interface
|
5 |
|
|
# ---------
|
6 |
|
|
# new() :
|
7 |
|
|
# setbase() :
|
8 |
|
|
# unsetbase() :
|
9 |
|
|
# get(url, destination) :
|
10 |
|
|
|
11 |
sashby |
1.2 |
package URL::URL_http;
|
12 |
|
|
use LWP::Simple qw(&getstore);
|
13 |
williamc |
1.1 |
|
14 |
|
|
sub new {
|
15 |
|
|
my $class=shift;
|
16 |
|
|
$self={};
|
17 |
|
|
bless $self, $class;
|
18 |
|
|
$self->{path}="";
|
19 |
|
|
return $self;
|
20 |
|
|
}
|
21 |
|
|
|
22 |
|
|
sub setbase {
|
23 |
|
|
my $self=shift;
|
24 |
|
|
my $varhash=shift;
|
25 |
|
|
|
26 |
|
|
if ( exists $$varhash{'base'} ) {
|
27 |
|
|
$self->{path}=$$varhash{'base'};
|
28 |
|
|
}
|
29 |
|
|
}
|
30 |
|
|
|
31 |
|
|
sub unsetbase {
|
32 |
|
|
my $self=shift;
|
33 |
|
|
$self->{path}="";
|
34 |
|
|
}
|
35 |
|
|
|
36 |
|
|
sub get {
|
37 |
|
|
my $self=shift;
|
38 |
|
|
my $url=shift;
|
39 |
|
|
my $filename=shift;
|
40 |
|
|
|
41 |
|
|
my $urlfile;
|
42 |
|
|
|
43 |
|
|
$fullurl=$self->{path}.$url;
|
44 |
sashby |
1.2 |
# open (STORE, ">$filename") || carp "unable to open file $filename $!\n";
|
45 |
|
|
# print STORE (&getstore 'http:'.$urlfile);
|
46 |
|
|
# close STORE;
|
47 |
williamc |
1.1 |
}
|
48 |
sashby |
1.2 |
# my $http_response_val = &getstore($toolurl, $filename);
|
49 |
|
|
|
50 |
|
|
# Check the HTTP status. If doc not found, exit:
|
51 |
|
|
# if ($http_response_val != 200)
|
52 |
|
|
# {
|
53 |
|
|
# my ($server,$doc) = ($urlv =~ m|//(.*?)/(.*)|);
|
54 |
|
|
# $::scram->scramerror("Unable to set up $toolname: $doc not found on $server!");
|
55 |
|
|
# }
|
56 |
|
|
# else
|
57 |
|
|
# {
|
58 |
|
|
# $toolfile=$filename;
|
59 |
|
|
# }
|
60 |
|
|
|
61 |
|
|
1;
|