1HTTP::DAV::Resource(3)User Contributed Perl DocumentationHTTP::DAV::Resource(3)
2
3
4
6 HTTP::DAV::Resource - Represents and interfaces with WebDAV Resources
7
9 Sample
10
12 Description here
13
15 new Returns a new resource represented by the URI.
16
17 $r = HTTP::DAV::Resource->new(
18 -uri => $uri,
19 -LockedResourceList => $locks,
20 -Comms => $comms
21 -Client => $dav_client
22 );
23
24 On creation a Resource object needs 2 other objects passed in:
25
26 1. a "ResourceList" Object. This list will be added to if you lock
27 this Resource.
28
29 2. a "Comms" Object. This object will be used for HTTP
30 communication.
31
32 2. a "HTTP::DAV" Object. This object is where all locks are stored
33
35 get/GET
36 Performs an HTTP GET and returns a DAV::Response object.
37
38 $response = $resource->get;
39 print $resource->get_content if ($response->is_success);
40
41 put/PUT
42 Performs an HTTP PUT and returns a DAV::Response object.
43
44 $response = $resource->put( $string );
45
46 $string is be passed as the body.
47
48 e.g.
49 $response = $resource->put($string);
50 print $resource->get_content if ($response->is_success);
51
52 Will use a Lock header if this resource was previously locked.
53
54 copy
55 Not implemented
56
57 move
58 Not implemented
59
60 delete
61 Performs an HTTP DELETE and returns a DAV::Response object.
62
63 $response = $resource->delete;
64 print "Delete successful" if ($response->is_success);
65
66 Will use a Lock header if this resource was previously locked.
67
68 options
69 Performs an HTTP OPTIONS and returns a DAV::Response object.
70
71 $response = $resource->options;
72 print "Yay for PUT!" if $resource->is_option("PUT");
73
74 mkcol
75 Performs a WebDAV MKCOL request and returns a DAV::Response object.
76
77 $response = $resource->mkcol;
78 print "MKCOL successful" if ($response->is_success);
79
80 Will use a Lock header if this resource was previously locked.
81
82 proppatch
83 xxx
84
85 propfind
86 Performs a WebDAV PROPFIND request and returns a DAV::Response
87 object.
88
89 $response = $resource->propfind;
90 if ($response->is_success) {
91 print "PROPFIND successful\n";
92 print $resource->get_property("displayname") . "\n";
93 }
94
95 A successful PROPFIND fills the object with much data about the
96 Resource. Including:
97 displayname
98 ...
99 TODO
100
101 lock
102 Performs a WebDAV LOCK request and returns a DAV::Response object.
103
104 $resource->lock(
105 -owner => "Patrick Collins",
106 -depth => "infinity"
107 -scope => "exclusive",
108 -type => "write"
109 -timeout => TIMEOUT',
110 )
111
112 lock takes the following arguments.
113
114 owner - Indicates who locked this resource
115
116 The default value is:
117 DAV.pm/v$DAV::VERSION ($$)
118
119 e.g. DAV.pm/v0.1 (123)
120
121 If you use a URL as the owner, the module will automatically
122 indicate to the server that is is a URL
123 (<D:href>http://...</D:href>)
124
125 depth - Indicates the depth of the lock.
126
127 Legal values are 0 or infinity. (1 is not allowed).
128
129 The default value is infinity.
130
131 A lock value of 0 on a collection will lock just the collection but
132 not it's members, whereas a lock value of infinity will lock the
133 collection and all of it's members.
134
135 scope - Indicates the scope of the lock.
136
137 Legal DAV values are "exclusive" or "shared".
138
139 The default value is exclusive.
140
141 See section 6.1 of RFC2518 for a description of shared vs.
142 exclusive locks.
143
144 type - Indicates the type of lock (read, write, etc)
145
146 The only legal DAV value currently is "write".
147
148 The default value is write.
149
150 timeout - Indicates when the lock will timeout
151
152 The timeout value may be one of, an Absolute Date, a Time Offset
153 from now, or the word "infinity".
154
155 The default value is "infinity".
156
157 The following are all valid timeout values:
158
159 Time Offset:
160 30s 30 seconds from now
161 10m ten minutes from now
162 1h one hour from now
163 1d tomorrow
164 3M in three months
165 10y in ten years time
166
167 Absolute Date:
168
169 timeout at the indicated time & date (UTC/GMT)
170 2000-02-31 00:40:33
171
172 timeout at the indicated date (UTC/GMT)
173 2000-02-31
174
175 You can use any of the Absolute Date formats specified in
176 HTTP::Date (see perldoc HTTP::Date)
177
178 Note: the DAV server may choose to ignore your specified timeout.
179
180 unlock
181 Performs a WebDAV UNLOCK request and returns a DAV::Response
182 object.
183
184 $response = $resource->unlock()
185 $response = $resource->unlock( -force => 1 )
186 $response = $resource->unlock(
187 -token => "opaquelocktoken:1342-21423-2323" )
188
189 This method will automatically use the correct locktoken If: header
190 if this resource was previously locked.
191
192 force - Synonymous to calling $resource->forcefully_unlock_all.
193
194 forcefully_unlock_all
195 Remove all locks from a resource and return the last DAV::Response
196 object. This method take no arguments.
197
198 $response = $resource->forcefully_unlock_all;
199
200 This method will perform a lockdiscovery against the resource to
201 determine all of the current locks. Then it will UNLOCK them one by
202 one. unlock( -token => locktoken ).
203
204 This unlock process is achievable because DAV does not enforce any
205 security over locks.
206
207 Note: this method returns the LAST unlock response (this is
208 sufficient to indicate the success of the sequence of unlocks). If
209 an unlock fails, it will bail and return that response. For
210 instance, In the event that there are 3 shared locks and the second
211 unlock method fails, then you will get returned the unsuccessful
212 second response. The 3rd unlock will not be attempted.
213
214 Don't run with this knife, you could hurt someone (or yourself).
215
216 steal_lock
217 Removes all locks from a resource, relocks it in your name and
218 returns the DAV::Response object for the lock command. This method
219 takes no arguments.
220
221 $response = $resource->steal_lock;
222
223 Synonymous to forcefully_unlock_all() and then lock().
224
225 lockdiscovery
226 Discover the locks held against this resource and return a
227 DAV::Response object. This method take no arguments.
228
229 $response = $resource->lockdiscovery;
230 @locks = $resource->get_locks if $response->is_success;
231
232 This method is in fact a simplified version of propfind().
233
234 as_string
235 Returns a string representation of the object. Mainly useful for
236 debugging purposes. It takes no arguments.
237
238 print $resource->as_string
239
241 is_option
242 Returns a boolean indicating whether this resource supports the
243 option passed in as a string. The option match is case insensitive
244 so, PUT and Put are should both work.
245
246 if ($resource->is_option( "PUT" ) ) {
247 $resource->put( ... )
248 }
249
250 Note: this routine automatically calls the options() routine which
251 makes the request to the server. Subsequent calls to is_option will
252 use the cached option list. To force a rerequest to the server call
253 options()
254
255 is_locked
256 Returns a boolean indicating whether this resource is locked.
257
258 @lock = $resource->is_locked( -owned=>[1|0] );
259
260 owned - this parameter is used to ask, is this resource locked by
261 me?
262
263 Note: You must have already called propfind() or lockdiscovery()
264
265 e.g. Is the resource locked at all?
266 print "yes" if $resource->is_locked();
267
268 Is the resource locked by me?
269 print "yes" if $resource->is_locked( -owned=>1 );
270
271 Is the resource locked by someone other than me?
272 print "yes" if $resource->is_locked( -owned=>0 );
273
274 is_collection
275 Returns a boolean indicating whether this resource is a collection.
276
277 print "Directory" if ( $resource->is_collection );
278
279 You must first have performed a propfind.
280
281 get_uri
282 Returns the URI object for this resource.
283
284 print "URL is: " . $resource->get_uri()->as_string . "\n";
285
286 See the URI manpage from the LWP libraries (perldoc URI)
287
288 get_property
289 Returns a property value. Takes a string as an argument.
290
291 print $resource->get_property( "displayname" );
292
293 You must first have performed a propfind.
294
295 get_options
296 Returns an array of options allowed on this resource. Note: If
297 $resource->options has not been called then it will return an empty
298 array.
299
300 @options = $resource->get_options
301
302 get_content
303 Returns the resource's content/body as a string. The content is
304 typically the result of a GET.
305
306 $content = $resource->get_content
307
308 get_content_ref
309 Returns the resource's content/body as a reference to a string.
310 This is useful and more efficient if the content is large.
311
312 ${$resource->get_content_ref} =~ s/\bfoo\b/bar/g;
313
314 Note: You must have already called get()
315
316 get_lock
317 Returns the DAV::Lock object if it exists. Requires opaquelocktoken
318 passed as a parameter.
319
320 $lock = $resource->get_lock( "opaquelocktoken:234214--342-3444" );
321
322 get_locks
323 Returns a list of any DAV::Lock objects held against the resource.
324
325 @lock = $resource->get_locks( -owned=>[1|0] );
326
327 owned - this parameter indicates which locks you want.
328 - '1', requests any of my locks. (Locked by this DAV instance).
329 - '0' ,requests any locks not owned by us.
330 - any other value or no value, requests ALL locks.
331
332 Note: You must have already called propfind() or lockdiscovery()
333
334 e.g.
335 Give me my locks
336 @lock = $resource->get_locks( -owned=>1 );
337
338 Give me all locks
339 @lock = $resource->get_locks();
340
341 get_lockedresourcelist
342 get_parentresourcelist
343 get_comms
344 set_parent_resourcelist
345 $resource->set_parent_resourcelist( $resourcelist )
346
347 Sets the parent resource list (ask the question, which collection
348 am I a member of?). See HTTP::DAV::ResourceList.
349
350
351
352perl v5.32.1 2021-01-27 HTTP::DAV::Resource(3)