line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Math::Matlab::Remote; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
746
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
41
|
|
4
|
1
|
|
|
1
|
|
5
|
use vars qw($VERSION $URI $TIMEOUT $USER $PASS); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
108
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
BEGIN { |
7
|
1
|
|
|
1
|
|
24
|
$VERSION = sprintf "%d.%03d", q$Revision: 1.6 $ =~ /: (\d+)\.(\d+)/; |
8
|
|
|
|
|
|
|
} |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
575
|
use Math::Matlab; |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
89
|
|
11
|
1
|
|
|
1
|
|
19
|
use base qw( Math::Matlab ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
616
|
|
12
|
|
|
|
|
|
|
|
13
|
1
|
|
|
1
|
|
2638
|
use HTTP::Request; |
|
1
|
|
|
|
|
30575
|
|
|
1
|
|
|
|
|
33
|
|
14
|
1
|
|
|
1
|
|
853
|
use HTTP::Response; |
|
1
|
|
|
|
|
7104
|
|
|
1
|
|
|
|
|
39
|
|
15
|
1
|
|
|
1
|
|
1267
|
use LWP::UserAgent; |
|
1
|
|
|
|
|
17865
|
|
|
1
|
|
|
|
|
33
|
|
16
|
1
|
|
|
1
|
|
1055
|
use URI::URL; |
|
1
|
|
|
|
|
4164
|
|
|
1
|
|
|
|
|
613
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
##----- assign defaults, unless already set externally ----- |
19
|
|
|
|
|
|
|
$URI = '' unless defined $URI; |
20
|
|
|
|
|
|
|
$TIMEOUT = 300 unless defined $TIMEOUT; ## default = 5 min |
21
|
|
|
|
|
|
|
$USER = '' unless defined $USER; |
22
|
|
|
|
|
|
|
$PASS = '' unless defined $PASS; |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
##----- Public Class Methods ----- |
25
|
|
|
|
|
|
|
sub new { |
26
|
1
|
|
|
1
|
1
|
416
|
my ($class, $href) = @_; |
27
|
1
|
50
|
|
|
|
14
|
my $self = { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
28
|
|
|
|
|
|
|
uri => defined($href->{uri}) ? $href->{uri} : $URI, |
29
|
|
|
|
|
|
|
timeout => defined($href->{timeout}) ? $href->{timeout} : $TIMEOUT, |
30
|
|
|
|
|
|
|
user => defined($href->{user}) ? $href->{user} : $USER, |
31
|
|
|
|
|
|
|
pass => defined($href->{pass}) ? $href->{pass} : $PASS, |
32
|
|
|
|
|
|
|
err_msg => '', |
33
|
|
|
|
|
|
|
result => '' |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
1
|
|
|
|
|
7
|
bless $self, $class; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
##----- Public Object Methods ----- |
40
|
|
|
|
|
|
|
sub execute { |
41
|
0
|
|
|
0
|
1
|
|
my ($self, $code, $rel_mwd) = @_; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
## set up the request |
44
|
0
|
|
0
|
|
|
|
my %form = ( |
45
|
|
|
|
|
|
|
'RAW_OUTPUT' => 1, |
46
|
|
|
|
|
|
|
'CODE' => $code, |
47
|
|
|
|
|
|
|
'REL_MWD' => $rel_mwd || '' |
48
|
|
|
|
|
|
|
); |
49
|
0
|
|
|
|
|
|
my $request = new HTTP::Request('POST' => $self->uri); |
50
|
0
|
|
|
|
|
|
$request->content_type('application/x-www-form-urlencoded'); |
51
|
0
|
|
|
|
|
|
my $curl = new URI::URL('http:'); |
52
|
0
|
|
|
|
|
|
$curl->query_form( %form ); |
53
|
0
|
|
|
|
|
|
$request->content($curl->equery); |
54
|
0
|
0
|
|
|
|
|
$request->authorization_basic($self->user, $self->pass) if $self->user; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
## set up the user agent |
57
|
0
|
|
|
|
|
|
my $ua = new LWP::UserAgent; |
58
|
0
|
|
|
|
|
|
$ua->agent( __PACKAGE__ . "/$VERSION " . $ua->agent); |
59
|
0
|
|
|
|
|
|
$ua->timeout($self->timeout); |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
## do the request |
62
|
0
|
|
|
|
|
|
my $response = $ua->request($request); |
63
|
|
|
|
|
|
|
|
64
|
0
|
0
|
|
|
|
|
if ($response->is_error) { |
65
|
0
|
|
|
|
|
|
$self->err_msg( $response->status_line ); |
66
|
0
|
|
|
|
|
|
return 0; |
67
|
|
|
|
|
|
|
} else { |
68
|
0
|
|
|
|
|
|
$self->{'result'} = $response->content; |
69
|
0
|
|
|
|
|
|
return 1; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
0
|
|
|
0
|
1
|
|
sub uri { my $self = shift; return $self->_getset('uri', @_); } |
|
0
|
|
|
|
|
|
|
74
|
0
|
|
|
0
|
1
|
|
sub timeout { my $self = shift; return $self->_getset('timeout', @_); } |
|
0
|
|
|
|
|
|
|
75
|
0
|
|
|
0
|
1
|
|
sub user { my $self = shift; return $self->_getset('user', @_); } |
|
0
|
|
|
|
|
|
|
76
|
0
|
|
|
0
|
1
|
|
sub pass { my $self = shift; return $self->_getset('pass', @_); } |
|
0
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |
79
|
|
|
|
|
|
|
__END__ |