line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SOAPjr::request; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
6
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
32
|
|
5
|
1
|
|
|
1
|
|
7
|
use File::Basename; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
96
|
|
6
|
1
|
|
|
1
|
|
1242
|
use File::Temp; |
|
1
|
|
|
|
|
26413
|
|
|
1
|
|
|
|
|
105
|
|
7
|
1
|
|
|
1
|
|
1064
|
use File::Copy; |
|
1
|
|
|
|
|
2836
|
|
|
1
|
|
|
|
|
68
|
|
8
|
1
|
|
|
1
|
|
850
|
use URI::Escape; |
|
1
|
|
|
|
|
1680
|
|
|
1
|
|
|
|
|
158
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
SOAPjr::request - the SOAPjr request object |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 1.0.3 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = "1.0.3"; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
See perldoc SOAPjr for more info. |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=cut |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
9
|
use base qw(SOAPjr::message); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
658
|
|
29
|
1
|
|
|
1
|
|
6
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
621
|
|
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _init { |
32
|
0
|
|
|
0
|
|
|
my $self = shift; |
33
|
0
|
|
|
|
|
|
$self->{server} = shift; |
34
|
0
|
|
|
|
|
|
my $query = shift; |
35
|
0
|
|
|
|
|
|
$self = $self->SUPER::_init(@_); |
36
|
0
|
|
|
|
|
|
my $update_count = $self->set($query); |
37
|
0
|
|
|
|
|
|
return $self; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub set { |
41
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
42
|
0
|
|
|
|
|
|
my $query = shift; |
43
|
0
|
|
|
|
|
|
my $cgi_query; |
44
|
0
|
|
|
|
|
|
my $count = 0; |
45
|
0
|
|
|
|
|
|
my $json; |
46
|
0
|
0
|
0
|
|
|
|
if (ref($query) ne 'HASH' && $query->can("param")) { |
47
|
|
|
|
|
|
|
# Make a copy |
48
|
0
|
|
|
|
|
|
$cgi_query = $query; |
49
|
0
|
|
|
|
|
|
my @names = $query->param; |
50
|
0
|
|
|
|
|
|
my %params = ( map { $_ => $query->param($_) } @names ); |
|
0
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
$query = { params => \%params }; |
52
|
|
|
|
|
|
|
} |
53
|
0
|
0
|
|
|
|
|
if (exists $query->{params}) { |
54
|
0
|
0
|
|
|
|
|
if (exists $query->{params}->{json} ) { |
55
|
0
|
|
|
|
|
|
my $url_decoded_json = uri_unescape($query->{params}->{json}); |
56
|
0
|
0
|
|
|
|
|
if ($self->{json}->can("decode")) { |
|
|
0
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# Modern-ish 2.x JSON API |
58
|
0
|
|
|
|
|
|
$json = $self->{json}->decode( $url_decoded_json ); |
59
|
|
|
|
|
|
|
} elsif ($self->{json}->can("jsonToObj")) { |
60
|
|
|
|
|
|
|
# Olde Version 1.x JSON API |
61
|
0
|
|
|
|
|
|
$json = $self->{json}->jsonToObj( $url_decoded_json ); |
62
|
|
|
|
|
|
|
} else { |
63
|
|
|
|
|
|
|
# TODO: handle unknown JSON API |
64
|
0
|
|
|
|
|
|
carp "WARNING: unknown JSON API"; |
65
|
|
|
|
|
|
|
} |
66
|
0
|
0
|
|
|
|
|
if ( $json->{HEAD} ) { |
67
|
0
|
|
|
|
|
|
$self->{_data}->{HEAD} = $json->{HEAD}; |
68
|
|
|
|
|
|
|
} else { |
69
|
0
|
|
|
|
|
|
carp "WARNING: HEAD missing"; |
70
|
|
|
|
|
|
|
} |
71
|
0
|
0
|
|
|
|
|
if ( $json->{BODY} ) { |
72
|
0
|
|
|
|
|
|
$self->{_data}->{BODY} = $json->{BODY}; |
73
|
|
|
|
|
|
|
} else { |
74
|
0
|
|
|
|
|
|
carp "WARNING: BODY missing"; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
# TODO: what about json_type |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Check for "RELATED" components |
79
|
0
|
0
|
|
|
|
|
if (exists $json->{HEAD}->{related}) { |
80
|
0
|
|
|
|
|
|
while (my ($k, $v) = each %{$json->{HEAD}->{related}}) { |
|
0
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# TODO: handle other types of related content |
82
|
0
|
0
|
|
|
|
|
next unless ($v eq 'binary'); |
83
|
|
|
|
|
|
|
# Append file data |
84
|
0
|
0
|
|
|
|
|
unless ($cgi_query) { |
85
|
0
|
|
|
|
|
|
carp "WARNING: related item is a file but query not a CGI object"; |
86
|
|
|
|
|
|
|
} |
87
|
0
|
|
|
|
|
|
my $filename = $cgi_query->param($k); |
88
|
0
|
|
|
|
|
|
my $fh = $cgi_query->upload($k); |
89
|
|
|
|
|
|
|
# Save CGI tmp file into our own tmp file (for lifecycle |
90
|
|
|
|
|
|
|
# reasons) |
91
|
0
|
|
|
|
|
|
my $tmp_fh = File::Temp->new(UNLINK => 0); |
92
|
0
|
|
|
|
|
|
my $tmp_file = $tmp_fh->filename; |
93
|
0
|
0
|
|
|
|
|
copy ($fh, $tmp_file) or die $!; |
94
|
0
|
|
|
|
|
|
close $tmp_fh; |
95
|
0
|
|
|
|
|
|
$self->{_data}->{BODY}->{$k}->{filepath} = $tmp_file; |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
} |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
0
|
|
|
|
|
|
return $self->SUPER::set( $query, $count ); |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=head1 AUTHOR |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
Rob Manson, |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=head1 BUGS |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
111
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
112
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head1 SUPPORT |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
perldoc SOAPjr |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
You can also look for information at: |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=over 4 |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * SOAPjr.org |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
L |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
L |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
L |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item * CPAN Ratings |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
L |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=item * Search CPAN |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
L |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=back |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
See L for further information on related RFC's and specifications. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
Copyright 2008 Rob Manson, Sean McCarthy and http://SOAPjr.org, some rights reserved. |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
This file is part of SOAPjr. |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
SOAPjr is free software: you can redistribute it and/or modify |
161
|
|
|
|
|
|
|
it under the terms of the GNU General Public License as published by |
162
|
|
|
|
|
|
|
the Free Software Foundation, either version 3 of the License, or |
163
|
|
|
|
|
|
|
(at your option) any later version. |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
SOAPjr is distributed in the hope that it will be useful, |
166
|
|
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of |
167
|
|
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
168
|
|
|
|
|
|
|
GNU General Public License for more details. |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License |
171
|
|
|
|
|
|
|
along with SOAPjr. If not, see . |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=cut |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
1; |