line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Perinci::AccessUtil::Check; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $DATE = '2014-10-23'; # DATE |
4
|
|
|
|
|
|
|
our $VERSION = '0.01'; # VERSION |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
508
|
use 5.010001; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
32
|
|
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
8
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
256
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
require Exporter; |
11
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
12
|
|
|
|
|
|
|
our @EXPORT_OK = qw(check_riap_res); |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub check_riap_res { |
15
|
6
|
|
|
6
|
1
|
1353
|
my $res = shift; |
16
|
|
|
|
|
|
|
|
17
|
6
|
|
50
|
|
|
19
|
my $ver = $res->[3]{'riap.v'} // 1.1; |
18
|
6
|
100
|
100
|
|
|
43
|
return [501, "Riap version returned by server ($ver) is not supported, ". |
19
|
|
|
|
|
|
|
"only recognize v1.1 and v1.2"] |
20
|
|
|
|
|
|
|
unless $ver == 1.1 || $ver == 1.2; |
21
|
|
|
|
|
|
|
|
22
|
5
|
100
|
|
|
|
10
|
if ($ver >= 1.2) { |
23
|
|
|
|
|
|
|
# check and strip riap.* |
24
|
3
|
|
|
|
|
4
|
for my $k (keys %{$res->[3]}) { |
|
3
|
|
|
|
|
9
|
|
25
|
5
|
50
|
|
|
|
68
|
next unless $k =~ /\Ariap\./; |
26
|
5
|
|
|
|
|
9
|
my $val = $res->[3]{$k}; |
27
|
5
|
100
|
|
|
|
17
|
if ($k eq 'riap.v') { |
|
|
100
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} elsif ($k eq 'riap.result_encoding') { |
29
|
2
|
100
|
|
|
|
11
|
return [501, "Unknown result_encoding returned by server ". |
30
|
|
|
|
|
|
|
"($val), only base64 is supported"] |
31
|
|
|
|
|
|
|
unless $val eq 'base64'; |
32
|
1
|
|
|
|
|
559
|
require MIME::Base64; |
33
|
1
|
|
50
|
|
|
622
|
$res->[2] = MIME::Base64::decode_base64($res->[2]//''); |
34
|
|
|
|
|
|
|
} else { |
35
|
1
|
|
|
|
|
10
|
return [501, "Unknown Riap attribute in result metadata ". |
36
|
|
|
|
|
|
|
"returned by server ($k)"]; |
37
|
|
|
|
|
|
|
} |
38
|
3
|
|
|
|
|
11
|
delete $res->[3]{$k}; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
3
|
|
|
|
|
16
|
$res; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1; |
46
|
|
|
|
|
|
|
# ABSTRACT: Utility module for Riap client/server |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
__END__ |