line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::RRP::Request; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
621
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
574
|
use Net::RRP::Exception::MissingCommandOption; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
use Net::RRP::Exception::MissingRequiredEntity; |
6
|
|
|
|
|
|
|
$Net::RRP::Request::VERSION = (split " ", '# $Id: Request.pm,v 1.4 2000/09/11 15:34:14 mkul Exp $ ')[3]; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
=head1 NAME |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
Net::RRP::Request - rrp request abstraction class |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
=head1 SYNOPSIS |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Net::RRP::Request; |
15
|
|
|
|
|
|
|
my $request = new Net::RRP::Request; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 DESCRIPTION |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
This is a base class for all Request::* classes. |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=cut |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head2 new |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
The constructor. You can pass entity && options attributes to this method. Example: |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $request = new Net::RRP::Request ( entity => new Net::RRP::Entity ( .... ), |
28
|
|
|
|
|
|
|
options => { key => 'value' } ); |
29
|
|
|
|
|
|
|
my $request1 = new Net::RRP::Request ( ); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new |
34
|
|
|
|
|
|
|
{ |
35
|
|
|
|
|
|
|
my ( $class, %params ) = @_; |
36
|
|
|
|
|
|
|
bless { %params }, $class; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head2 getName |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Return a *real* name of this request. You must overwrite this method at child class. Example: |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $requestName = $request->getName(); |
44
|
|
|
|
|
|
|
print STDERR "EntityName is $requestName\n"; |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=cut |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub getName |
49
|
|
|
|
|
|
|
{ |
50
|
|
|
|
|
|
|
die "Must be implemented at child class"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 setEntity |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Setup the rrp entity for this request. Example: |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
$request->setEntity ( new Net::RRP::Entity ( ... ) ); |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=cut |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub setEntity |
62
|
|
|
|
|
|
|
{ |
63
|
|
|
|
|
|
|
my ( $this, $entity ) = @_; |
64
|
|
|
|
|
|
|
my $old = $this->{entity}; |
65
|
|
|
|
|
|
|
$this->{entity} = $entity; |
66
|
|
|
|
|
|
|
$old; |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 getEntity |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Return a entity of this request. Example: |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
my $entity = $request->getEntity(); |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Can throw Net::RRP::Exception::MissingRequiredEntity exception |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub getEntity |
80
|
|
|
|
|
|
|
{ |
81
|
|
|
|
|
|
|
my $this = shift; |
82
|
|
|
|
|
|
|
$this->{entity} || throw Net::RRP::Exception::MissingRequiredEntity(); |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head2 getOption |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
Return a request option by $optionName. Example: |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
print $request->getOption ( $optionName ); |
90
|
|
|
|
|
|
|
print $request->getOption ( 'ttt' ); # no '-' here |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Can throw Net::RRP::Exception::MissingCommandOption() exception. |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=cut |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
sub getOption |
97
|
|
|
|
|
|
|
{ |
98
|
|
|
|
|
|
|
my ( $this, $optionName ) = @_; |
99
|
|
|
|
|
|
|
$this->{options}->{ lc ( $optionName ) } || throw Net::RRP::Exception::MissingCommandOption(); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=head2 setOption |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Set $optionName rrp request option to the $optionValue. Example: |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
$request->setOption ( $optionName => $optionValue ); |
107
|
|
|
|
|
|
|
$request->setOption ( tt => 'qq' ); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub setOption |
112
|
|
|
|
|
|
|
{ |
113
|
|
|
|
|
|
|
my ( $this, $optionName, $optionValue ) = @_; |
114
|
|
|
|
|
|
|
$optionName = lc ( $optionName ); |
115
|
|
|
|
|
|
|
my $old = $this->{options}->{$optionName}; |
116
|
|
|
|
|
|
|
$this->{options}->{$optionName} = $optionValue; |
117
|
|
|
|
|
|
|
$old; |
118
|
|
|
|
|
|
|
} |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 getOptions |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Return a hash ref to the request options. Example: |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
my $options = $request->gtOptions(); |
125
|
|
|
|
|
|
|
map { print "$_ = " . $options->{$_} } keys %$options; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
=cut |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
sub getOptions |
130
|
|
|
|
|
|
|
{ |
131
|
|
|
|
|
|
|
my $this = shift; |
132
|
|
|
|
|
|
|
$this->{options} |
133
|
|
|
|
|
|
|
} |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
=head2 isSuccessResponse |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
Return a true if response is successfull. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my $protocol = new Net::RRP::Protocol ( .... ); |
140
|
|
|
|
|
|
|
my $request = new Net::RRP::Request::Add ( .... ); |
141
|
|
|
|
|
|
|
$protocol->sendRequest ( $request ); |
142
|
|
|
|
|
|
|
my $response = $protocol->getResponse (); |
143
|
|
|
|
|
|
|
die "error" unless $request->isSuccessResponse ( $response ); |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub isSuccessResponse |
148
|
|
|
|
|
|
|
{ |
149
|
|
|
|
|
|
|
my ( $this, $response ) = @_; |
150
|
|
|
|
|
|
|
return 0 unless $response; |
151
|
|
|
|
|
|
|
return { 200 => 1, 220 => 1 }->{ $response->getCode() }; |
152
|
|
|
|
|
|
|
} |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
1; |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 AUTHOR AND COPYRIGHT |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Net::RRP::Request (C) Michael Kulakov, Zenon N.S.P. 2000 |
160
|
|
|
|
|
|
|
125124, 19, 1-st Jamskogo polja st, |
161
|
|
|
|
|
|
|
Moscow, Russian Federation |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
mkul@cpan.org |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
All rights reserved. |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
You may distribute this package under the terms of either the GNU |
168
|
|
|
|
|
|
|
General Public License or the Artistic License, as specified in the |
169
|
|
|
|
|
|
|
Perl README file. |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 SEE ALSO |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
L, L, L, RFC 2832, |
174
|
|
|
|
|
|
|
L, L |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
__END__ |