~ubuntu-branches/ubuntu/utopic/libhttp-dav-perl/utopic

« back to all changes in this revision

Viewing changes to doc/html/HTTP-DAV.html

  • Committer: Package Import Robot
  • Author(s): Steinar H. Gunderson
  • Date: 2013-03-14 19:32:14 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20130314193214-7ciunekfj7nhwqb5
Tags: 0.44-1
* New upstream release.
* Replace PREFIX with DESTDIR in make install; fixes lintian warning
  and prepares for change in ExtUtils::MakeMaker.
* Add ${misc:Depends} to Depends list, to make debhelper happy.
* Bump Standard-Version to 3.9.4.
  * Add build-arch and build-indep targets.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
<body>
12
12
 
 
13
 
 
14
<!-- INDEX BEGIN -->
 
15
<div name="index">
13
16
<p><a name="__index__"></a></p>
14
 
<!-- INDEX BEGIN -->
15
17
<!--
16
18
 
17
19
<ul>
35
37
        <li><a href="#see_also">SEE ALSO</a></li>
36
38
        <li><a href="#author_and_copyright">AUTHOR AND COPYRIGHT</a></li>
37
39
</ul>
 
40
 
38
41
-->
 
42
 
 
43
 
 
44
</div>
39
45
<!-- INDEX END -->
40
46
 
41
47
<p>
53
59
<pre>
54
60
   use HTTP::DAV;
55
61
  
56
 
   $d = new HTTP::DAV;
 
62
   $d = HTTP::DAV-&gt;new();
57
63
   $url = &quot;<a href="http://host.org:8080/dav/&quot">http://host.org:8080/dav/&quot</a>;;
58
 
  
59
 
   $d-&gt;credentials( -user=&gt;&quot;pcollins&quot;,-pass =&gt;&quot;mypass&quot;, 
60
 
                    -url =&gt;$url,      -realm=&gt;&quot;DAV Realm&quot; );
61
 
  
62
 
   $d-&gt;open( -url=&gt;&quot;$url )
 
64
 
 
65
   $d-&gt;credentials(
 
66
      -user  =&gt; &quot;pcollins&quot;,
 
67
      -pass  =&gt; &quot;mypass&quot;, 
 
68
      -url   =&gt; $url,
 
69
      -realm =&gt; &quot;DAV Realm&quot;
 
70
   );
 
71
 
 
72
   $d-&gt;open( -url =&gt; $url )
63
73
      or die(&quot;Couldn't open $url: &quot; .$d-&gt;message . &quot;\n&quot;);
64
 
  
 
74
 
65
75
   # Make a null lock on newdir
66
76
   $d-&gt;lock( -url =&gt; &quot;$url/newdir&quot;, -timeout =&gt; &quot;10m&quot; ) 
67
77
      or die &quot;Won't put unless I can lock for 10 minutes\n&quot;;</pre>
86
96
<p>HTTP::DAV is part of the PerlDAV project hosted at <a href="http://www.webdav.org/perldav/">http://www.webdav.org/perldav/</a> and has the following features:</p>
87
97
<ul>
88
98
<li>
89
 
<p>Full RFC2518 method support. OPTIONS, TRACE, GET, HEAD, DELETE, PUT, COPY, MOVE, PROPFIND, PROPPATCH, LOCK, UNLOCK.</p>
 
99
<p>Full <a href="http://www.ietf.org/rfc/rfc2518.txt" class="rfc">RFC2518</a> method support. OPTIONS, TRACE, GET, HEAD, DELETE, PUT, COPY, MOVE, PROPFIND, PROPPATCH, LOCK, UNLOCK.</p>
90
100
</li>
91
101
<li>
92
102
<p>A fully object-oriented API.</p>
104
114
<p>Basic AND Digest authentication support (Digest auth requires the MD5 library). See INSTALLATION.</p>
105
115
</li>
106
116
<li>
107
 
<p><a href="#item_dave"><code>dave</code></a>, a fully-functional ftp-style interface written on top of the HTTP::DAV API and bundled by default with the HTTP::DAV library. (If you've already installed HTTP::DAV, then dave will also have been installed (probably into /usr/local/bin). You can see it's man page by typing ``perldoc dave'' or going to <a href="http://www.webdav.org/perldav/dave/.">http://www.webdav.org/perldav/dave/.</a></p>
 
117
<p><a href="#dave"><code>dave</code></a>, a fully-functional ftp-style interface written on top of the HTTP::DAV API and bundled by default with the HTTP::DAV library. (If you've already installed HTTP::DAV, then dave will also have been installed (probably into /usr/local/bin). You can see it's man page by typing &quot;perldoc dave&quot; or going to <a href="http://www.webdav.org/perldav/dave/.">http://www.webdav.org/perldav/dave/.</a></p>
108
118
</li>
109
119
<li>
110
120
<p>It is built on top of the popular LWP (Library for WWW access in Perl). This means that HTTP::DAV inherits proxy support, redirect handling, basic (and digest) authorization and many other HTTP operations. See <code>LWP</code> for more information.</p>
111
121
</li>
112
122
<li>
113
 
<p>Popular server support. HTTP::DAV has been tested against the following servers: mod_dav, IIS5, Xythos webfile server and mydocsonline. The library is growing an impressive interoperability suite which also serves as useful ``sample scripts''. See ``make test'' and t/*.</p>
 
123
<p>Popular server support. HTTP::DAV has been tested against the following servers: mod_dav, IIS5, Xythos webfile server and mydocsonline. The library is growing an impressive interoperability suite which also serves as useful &quot;sample scripts&quot;. See &quot;make test&quot; and t/*.</p>
114
124
</li>
115
125
</ul>
116
 
<p><code>HTTP::DAV</code> essentially has two API's, one which is accessed through this module directly (HTTP::DAV) and is a simple abstraction to the rest of the HTTP::DAV::* Classes. The other interface consists of the HTTP::DAV::* classes which if required allow you to get ``down and dirty'' with your DAV and HTTP interactions.</p>
117
 
<p>The methods provided in <code>HTTP::DAV</code> should do most of what you want. If, however, you need more control over the client's operations or need more info about the server's responses then you will need to understand the rest of the HTTP::DAV::* interfaces. A good place to start is with the <a href="#item_http_3a_3adav_3a_3aresource"><code>HTTP::DAV::Resource</code></a> and <a href="#item_http_3a_3adav_3a_3aresponse"><code>HTTP::DAV::Response</code></a> documentation.</p>
 
126
<p><code>HTTP::DAV</code> essentially has two API's, one which is accessed through this module directly (HTTP::DAV) and is a simple abstraction to the rest of the HTTP::DAV::* Classes. The other interface consists of the HTTP::DAV::* classes which if required allow you to get &quot;down and dirty&quot; with your DAV and HTTP interactions.</p>
 
127
<p>The methods provided in <code>HTTP::DAV</code> should do most of what you want. If, however, you need more control over the client's operations or need more info about the server's responses then you will need to understand the rest of the HTTP::DAV::* interfaces. A good place to start is with the <a href="#http_dav_resource"><code>HTTP::DAV::Resource</code></a> and <a href="#http_dav_response"><code>HTTP::DAV::Response</code></a> documentation.</p>
118
128
<p>
119
129
</p>
120
130
<hr />
142
152
<h2><a name="things_you_need_to_know">THINGS YOU NEED TO KNOW</a></h2>
143
153
<p>In all of the methods specified in <a href="#public_methods">PUBLIC METHODS</a> there are some common concepts you'll need to understand:</p>
144
154
<ul>
145
 
<li><strong><a name="item_urls_represent_an_absolute_or_relative_uri_2e">URLs represent an absolute or relative URI.</a></strong>
 
155
<li><strong><a name="urls_represent_an_absolute_or_relative_uri" class="item">URLs represent an absolute or relative URI.</a></strong>
146
156
 
147
157
<pre>
148
158
  -url=&gt;&quot;host.org/dav_dir/&quot;  # Absolute
149
159
  -url=&gt;&quot;/dav_dir/&quot;          # Relative
150
160
  -url=&gt;&quot;file.txt&quot;           # Relative</pre>
151
 
<p>You can only use a relative URL if you have already ``open''ed an absolute URL.</p>
 
161
<p>You can only use a relative URL if you have already &quot;open&quot;ed an absolute URL.</p>
152
162
<p>The HTTP::DAV module now consistently uses the named parameter: URL. The lower-level HTTP::DAV::Resource interface inconsistently interchanges URL and URI. I'm working to resolve this, in the meantime, you'll just need to remember to use the right one by checking the documentation if you need to mix up your use of both interfaces.</p>
153
163
</li>
154
 
<li><strong><a name="item_globs">GLOBS</a></strong>
 
164
<li><strong><a name="globs" class="item">GLOBS</a></strong>
155
165
 
156
166
<p>Some methods accept wildcards in the URL. A wildcard can be used to indicate that the command should perform the command on all Resources that match the wildcard. These wildcards are called GLOBS.</p>
157
 
<p>The glob may contain the characters ``*'', ``?'' and the set operator ``[...]'' where ... contains multiple characters ([1t2]) or a range such ([1-5]). For the curious, the glob is converted to a regex and then matched: ``*'' to ``.*'', ``?'' to ``.'', and the [] is left untouched.</p>
158
 
<p>It is important to note that globs only operate at the leaf-level. For instance ``/my_dir/*/file.txt'' is not a valid glob.</p>
 
167
<p>The glob may contain the characters &quot;*&quot;, &quot;?&quot; and the set operator &quot;[...]&quot; where ... contains multiple characters ([1t2]) or a range such ([1-5]). For the curious, the glob is converted to a regex and then matched: &quot;*&quot; to &quot;.*&quot;, &quot;?&quot; to &quot;.&quot;, and the [] is left untouched.</p>
 
168
<p>It is important to note that globs only operate at the leaf-level. For instance &quot;/my_dir/*/file.txt&quot; is not a valid glob.</p>
159
169
<p>If a glob matches no URL's the command will fail (which normally means returns 0).</p>
160
 
<p>Globs are useful in conjunction with <a href="#item_callbacks">CALLBACKS</a> to provide feedback as each operation completes.</p>
 
170
<p>Globs are useful in conjunction with <a href="#callbacks">CALLBACKS</a> to provide feedback as each operation completes.</p>
161
171
<p>See the documentation for each method to determine whether it supports globbing.</p>
162
 
<p>Globs are useful for interactive style applications (see the source code for <a href="#item_dave"><code>dave</code></a> as an example).</p>
 
172
<p>Globs are useful for interactive style applications (see the source code for <a href="#dave"><code>dave</code></a> as an example).</p>
163
173
<p>Example globs:</p>
164
174
<pre>
165
175
   $dav1-&gt;delete(-url=&gt;&quot;/my_dir/file[1-3]&quot;);     # Matches file1, file2, file3
166
176
   $dav1-&gt;delete(-url=&gt;&quot;/my_dir/file[1-3]*.txt&quot;);# Matches file1*.txt,file2*.txt,file3*.txt
167
177
   $dav1-&gt;delete(-url=&gt;&quot;/my_dir/*/file.txt&quot;);    # Invalid. Can only match at leaf-level</pre>
168
178
</li>
169
 
<li><strong><a name="item_callbacks">CALLBACKS</a></strong>
 
179
<li><strong><a name="callbacks" class="item">CALLBACKS</a></strong>
170
180
 
171
181
<p>Callbacks are used by some methods (primarily get and put) to give the caller some insight as to how the operation is progressing. A callback allows you to define a subroutine as defined below and pass a reference (\&amp;ref) to the method.</p>
172
182
<p>The rationale behind the callback is that a recursive get/put or an operation against many files (using a <code>glob</code>) can actually take a long time to complete.</p>
180
190
   }</p>
181
191
<p>The <code>status</code> argument specifies whether the operation has succeeded (1), failed (0), or is in progress (-1).</p>
182
192
<p>The <code>mesg</code> argument is a status message. The status message could contain any string and often contains useful error messages or success messages.</p>
183
 
<p>The <code>url</code> the remote URL.</p>
184
 
<p>The <code>so_far</code>, <code>length</code> - these parameters indicate how many bytes have been downloaded and how many we should expect. This is useful for doing ``56% to go'' style-gauges.</p>
185
 
<p>The <code>data</code> parameter - is the actual data transferred. The <code>cat</code> command uses this to print the data to the screen. This value will be empty for <a href="#item_put"><code>put</code></a>.</p>
186
 
<p>See the source code of <a href="#item_dave"><code>dave</code></a> for a useful sample of how to setup a callback.</p>
 
193
<p>The <a href="#url"><code>url</code></a> the remote URL.</p>
 
194
<p>The <code>so_far</code>, <code>length</code> - these parameters indicate how many bytes have been downloaded and how many we should expect. This is useful for doing &quot;56% to go&quot; style-gauges.</p>
 
195
<p>The <code>data</code> parameter - is the actual data transferred. The <code>cat</code> command uses this to print the data to the screen. This value will be empty for <a href="#put"><code>put</code></a>.</p>
 
196
<p>See the source code of <a href="#dave"><code>dave</code></a> for a useful sample of how to setup a callback.</p>
187
197
<p>Note that these arguments are NOT named parameters.</p>
188
 
<p>All error messages set during a ``multi-operation'' request (for instance a recursive get/put) are also retrievable via the <a href="#item_errors"><code>errors()</code></a> function once the operation has completed. See <code>ERROR HANDLING</code> for more information.</p>
 
198
<p>All error messages set during a &quot;multi-operation&quot; request (for instance a recursive get/put) are also retrievable via the <a href="#errors"><code>errors()</code></a> function once the operation has completed. See <code>ERROR HANDLING</code> for more information.</p>
189
199
</li>
190
200
</ul>
191
201
<p>
192
202
</p>
193
203
<h2><a name="public_methods">PUBLIC METHODS</a></h2>
194
204
<dl>
195
 
<dt><strong><a name="item_new"><strong>new(USERAGENT)</strong></a></strong></dt>
 
205
<dt><strong><a name="new" class="item"><strong>new(USERAGENT)</strong></a></strong></dt>
 
206
 
 
207
<dt><strong><strong>new(USERAGENT, HEADERS)</strong></strong></dt>
196
208
 
197
209
<dd>
198
210
<p>Creates a new <code>HTTP::DAV</code> client</p>
199
211
<pre>
200
 
 $d = HTTP::DAV-&gt;new()</pre>
201
 
<p>The <code>-useragent</code> parameter expects an <code>HTTP::DAV::UserAgent</code> object. See the <a href="#item_dave"><code>dave</code></a> program for an advanced example of a custom UserAgent that interactively prompts the user for their username and password.</p>
 
212
 $d = HTTP::DAV-&gt;new();</pre>
 
213
<p>The <code>-useragent</code> parameter allows you to pass your own <strong>user agent object</strong> and expects an <code>HTTP::DAV::UserAgent</code> object. See the <a href="#dave"><code>dave</code></a> program for an advanced example of a custom UserAgent that interactively prompts the user for their username and password.</p>
 
214
<p>The <code>-headers</code> parameter allows you to specify a list of headers to be sent along with all requests. This can be either a hashref like:</p>
 
215
<pre>
 
216
  { &quot;X-My-Header&quot; =&gt; &quot;value&quot;, ... }</pre>
 
217
<p>or a <a href="HTTP/Headers.html">the HTTP::Headers manpage</a> object.</p>
202
218
</dd>
203
 
<dt><strong><a name="item_credentials"><strong>credentials(USER,PASS,[URL],[REALM])</strong></a></strong></dt>
 
219
<dt><strong><a name="credentials" class="item"><strong>credentials(USER,PASS,[URL],[REALM])</strong></a></strong></dt>
204
220
 
205
221
<dd>
206
222
<p>sets authorization credentials for a <code>URL</code> and/or <code>REALM</code>.</p>
213
229
                  -user=&gt;'pcollins',
214
230
                  -pass=&gt;'mypass');</pre>
215
231
</dd>
216
 
<dt><strong><a name="item_debuglevel"><strong>DebugLevel($val)</strong></a></strong></dt>
 
232
<dt><strong><a name="debuglevel" class="item"><strong>DebugLevel($val)</strong></a></strong></dt>
217
233
 
218
234
<dd>
219
235
<p>sets the debug level to <code>$val</code>. 0=off 3=noisy.</p>
220
236
<p><code>$val</code> default is 0.</p>
221
237
<p>returns no value.</p>
222
 
<p>When the value is greater than 1, the <a href="#item_http_3a_3adav_3a_3acomms"><code>HTTP::DAV::Comms</code></a> module will log all of the client&lt;=&gt;server interactions into /tmp/perldav_debug.txt.</p>
 
238
<p>When the value is greater than 1, the <a href="#http_dav_comms"><code>HTTP::DAV::Comms</code></a> module will log all of the client&lt;=&gt;server interactions into /tmp/perldav_debug.txt.</p>
223
239
</dd>
224
240
</dl>
225
241
<p>
227
243
<h2><a name="dav_operations">DAV OPERATIONS</a></h2>
228
244
<p>For all of the following operations, URL can be absolute (http://host.org/dav/) or relative (../dir2/). The only operation that requires an absolute URL is open.</p>
229
245
<dl>
230
 
<dt><strong><a name="item_copy"><strong>copy(URL,DEST,[OVERWRITE],[DEPTH])</strong></a></strong></dt>
 
246
<dt><strong><a name="copy" class="item"><strong>copy(URL,DEST,[OVERWRITE],[DEPTH])</strong></a></strong></dt>
231
247
 
232
248
<dd>
233
249
<p>copies one remote resource to another</p>
234
250
<dl>
235
 
<dt><strong><a name="item__2durl"><code>-url</code></a></strong></dt>
 
251
<dt><strong><a name="url" class="item"><code>-url</code></a></strong></dt>
236
252
 
237
253
<dd>
238
254
<p>is the remote resource you'd like to copy. Mandatory</p>
239
255
</dd>
240
 
<dt><strong><a name="item__2ddest"><code>-dest</code></a></strong></dt>
 
256
<dt><strong><a name="dest" class="item"><code>-dest</code></a></strong></dt>
241
257
 
242
258
<dd>
243
259
<p>is the remote target for the copy command. Mandatory</p>
244
260
</dd>
245
 
<dt><strong><a name="item__2doverwrite"><code>-overwrite</code></a></strong></dt>
 
261
<dt><strong><a name="overwrite" class="item"><code>-overwrite</code></a></strong></dt>
246
262
 
247
263
<dd>
248
 
<p>optionally indicates whether the server should fail if the target exists. Valid values are ``T'' and ``F'' (1 and 0 are synonymous). Default is T.</p>
 
264
<p>optionally indicates whether the server should fail if the target exists. Valid values are &quot;T&quot; and &quot;F&quot; (1 and 0 are synonymous). Default is T.</p>
249
265
</dd>
250
 
<dt><strong><a name="item__2ddepth"><code>-depth</code></a></strong></dt>
 
266
<dt><strong><a name="depth" class="item"><code>-depth</code></a></strong></dt>
251
267
 
252
268
<dd>
253
 
<p>optionally indicates whether the server should do a recursive copy or not. Valid values are 0 and (1 or ``infinity''). Default is ``infinity'' (1).</p>
 
269
<p>optionally indicates whether the server should do a recursive copy or not. Valid values are 0 and (1 or &quot;infinity&quot;). Default is &quot;infinity&quot; (1).</p>
254
270
</dd>
255
271
</dl>
256
272
<p>The return value is always 1 or 0 indicating success or failure.</p>
257
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
 
273
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
258
274
<p>Note: if either <code>'URL'</code> or <code>'DEST'</code> are locked by this dav client, then the lock headers will be taken care of automatically. If the either of the two URL's are locked by someone else, the server should reject the request.</p>
259
275
<p><strong>copy examples:</strong></p>
260
276
<pre>
273
289
<pre>
274
290
  $d-&gt;copy(&quot;file.txt&quot;,&quot;/dav_dir/dir2/new_file.txt&quot;)</pre>
275
291
</dd>
276
 
<dt><strong><a name="item_cwd"><strong>cwd(URL)</strong></a></strong></dt>
 
292
<dt><strong><a name="cwd" class="item"><strong>cwd(URL)</strong></a></strong></dt>
277
293
 
278
294
<dd>
279
295
<p>changes the remote working directory.</p>
283
299
  $d-&gt;cwd(&quot;../dir2&quot;);
284
300
  $d-&gt;cwd(-url=&gt;&quot;../dir1&quot;);</pre>
285
301
<p>The return value is always 1 or 0 indicating success or failure.</p>
286
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
 
302
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
287
303
<p>You can not cwd to files, only collections (directories).</p>
288
304
</dd>
289
 
<dt><strong><a name="item_delete"><strong>delete(URL)</strong></a></strong></dt>
 
305
<dt><strong><a name="delete" class="item"><strong>delete(URL)</strong></a></strong></dt>
290
306
 
291
307
<dd>
292
308
<p>deletes a remote resource.</p>
296
312
  $d-&gt;delete(&quot;./dir1&quot;);
297
313
  $d-&gt;delete(-url=&gt;&quot;/dav_dir/dir2/file*&quot;,-callback=&gt;\&amp;mycallback);</pre>
298
314
</dd>
299
 
<dt><strong><code>-url</code></strong></dt>
 
315
<dt><strong><a name="url2" class="item"><a href="#url"><code>-url</code></a></a></strong></dt>
300
316
 
301
317
<dd>
302
 
<p>is the remote <code>resource(s)</code> you'd like to delete. It can be a file, directory or <code>glob</code>.</p>
 
318
<p>is the remote resource(s) you'd like to delete. It can be a file, directory or <code>glob</code>.</p>
303
319
</dd>
304
 
<dt><strong><a name="item__2dcallback_is_a_reference_to_a_callback_function_"><a href="#item__2dcallback"><code>-callback</code></a>                                                                                                                                                                    is a reference to a callback function which will be called everytime a file is deleted. This is mainly useful when used in conjunction with <a href="#item_globs">GLOBS</a> deletes. See <em>callbacks</em></a></strong></dt>
 
320
<dt><strong><a name="callback_is_a_reference_to_a_callback_function_which_will_be_called_everytime_a_file_is_deleted_this_is_mainly_useful_when_used_in_conjunction_with_globs_deletes_see_callbacks" class="item"><a href="#callback"><code>-callback</code></a>                                                                                                                                                                    is a reference to a callback function which will be called everytime a file is deleted. This is mainly useful when used in conjunction with <a href="#globs">GLOBS</a> deletes. See <em>callbacks</em></a></strong></dt>
305
321
 
306
322
<dd>
307
323
<p>The return value is always 1 or 0 indicating success or failure.</p>
308
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
309
 
<p>This command will recursively delete directories. BE CAREFUL of uninitialised file variables in situation like this: $d-&gt;delete(``$dir/$file''). This will trash your $dir if $file is not set.</p>
 
324
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
 
325
<p>This command will recursively delete directories. BE CAREFUL of uninitialised file variables in situation like this: $d-&gt;<a href="#delete"><code>delete(&quot;$dir/$file&quot;)</code></a>. This will trash your $dir if $file is not set.</p>
310
326
</dd>
311
 
<dt><strong><a name="item_get"><strong>get(URL,[TO],[CALLBACK])</strong></a></strong></dt>
 
327
<dt><strong><a name="get" class="item"><strong>get(URL,[TO],[CALLBACK])</strong></a></strong></dt>
312
328
 
313
329
<dd>
314
330
<p>downloads the file or directory at <code>URL</code> to the local location indicated by <code>TO</code>.</p>
315
331
<dl>
316
 
<dt><strong><code>-url</code></strong></dt>
 
332
<dt><strong><a name="url3" class="item"><a href="#url"><code>-url</code></a></a></strong></dt>
317
333
 
318
334
<dd>
319
 
<p>is the remote resource you'd like to get. It can be a file or directory or a ``glob''.</p>
 
335
<p>is the remote resource you'd like to get. It can be a file or directory or a &quot;glob&quot;.</p>
320
336
</dd>
321
 
<dt><strong><a name="item__2dto"><code>-to</code></a></strong></dt>
 
337
<dt><strong><a name="to" class="item"><code>-to</code></a></strong></dt>
322
338
 
323
339
<dd>
324
340
<p>is where you'd like to put the remote resource. The -to parameter can be:</p>
328
344
 - a B&lt;FileHandle reference&gt;.</pre>
329
345
<pre>
330
346
 - a reference to a B&lt;scalar object&gt; into which the contents will be saved.</pre>
331
 
<p>If the <a href="#item__2durl"><code>-url</code></a> matches multiple files (via a glob or a directory download), then the <a href="#item_get"><code>get</code></a> routine will return an error if you try to use a FileHandle reference or a scalar reference.</p>
 
347
<p>If the <a href="#url"><code>-url</code></a> matches multiple files (via a glob or a directory download), then the <a href="#get"><code>get</code></a> routine will return an error if you try to use a FileHandle reference or a scalar reference.</p>
332
348
</dd>
333
 
<dt><strong><a name="item__2dcallback"><code>-callback</code></a></strong></dt>
 
349
<dt><strong><a name="callback" class="item"><code>-callback</code></a></strong></dt>
334
350
 
335
351
<dd>
336
 
<p>is a reference to a callback function which will be called everytime a file is completed downloading. The idea of the callback function is that some recursive get's can take a very long time and the user may require some visual feedback. See <a href="#item_callbacks">CALLBACKS</a> for an examples and how to use a callback.</p>
 
352
<p>is a reference to a callback function which will be called everytime a file is completed downloading. The idea of the callback function is that some recursive get's can take a very long time and the user may require some visual feedback. See <a href="#callbacks">CALLBACKS</a> for an examples and how to use a callback.</p>
337
353
</dd>
338
354
</dl>
339
 
<p>The return value of get is always 1 or 0 indicating whether the entire get sequence was a success or if there was ANY failures. For instance, in a recursive get, if the server couldn't open 1 of the 10 remote files, for whatever reason, then the return value will be 0. This is so that you can have your script call the <a href="#item_errors"><code>errors()</code></a> routine to handle error conditions.</p>
 
355
<p>The return value of get is always 1 or 0 indicating whether the entire get sequence was a success or if there was ANY failures. For instance, in a recursive get, if the server couldn't open 1 of the 10 remote files, for whatever reason, then the return value will be 0. This is so that you can have your script call the <a href="#errors"><code>errors()</code></a> routine to handle error conditions.</p>
340
356
<p>Previous versions of HTTP::DAV allowed the return value to be the file contents if no -to attribute was supplied. This functionality is deprecated.</p>
341
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
 
357
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
342
358
<p><strong>get examples:</strong></p>
343
359
<pre>
344
360
  $d-&gt;open(&quot;host.org/dav_dir/&quot;);</pre>
373
389
<pre>
374
390
  $d-&gt;get(&quot;/dav_dir/*/index.html&quot;,&quot;/tmp&quot;); # Can not glob like this.</pre>
375
391
</dd>
376
 
<dt><strong><a name="item_lock"><strong>lock([URL],[OWNER],[DEPTH],[TIMEOUT],[SCOPE],[TYPE])</strong></a></strong></dt>
 
392
<dt><strong><a name="lock" class="item"><strong>lock([URL],[OWNER],[DEPTH],[TIMEOUT],[SCOPE],[TYPE])</strong></a></strong></dt>
377
393
 
378
394
<dd>
379
395
<p>locks a resource. If URL is not specified, it will lock the current working resource (opened resource).</p>
384
400
             -scope   =&gt; &quot;exclusive&quot;,
385
401
             -type    =&gt; &quot;write&quot;,
386
402
             -timeout =&gt; &quot;10h&quot; )</pre>
387
 
<p>See <a href="#item_http_3a_3adav_3a_3aresource"><code>HTTP::DAV::Resource</code></a> <a href="#item_lock"><code>lock()</code></a> for details of the above parameters.</p>
 
403
<p>See <a href="#http_dav_resource"><code>HTTP::DAV::Resource</code></a> <a href="#lock"><code>lock()</code></a> for details of the above parameters.</p>
388
404
<p>The return value is always 1 or 0 indicating success or failure.</p>
389
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
390
 
<p>When you lock a resource, the lock is held against the current HTTP::DAV object. In fact, the locks are held in a <a href="#item_http_3a_3adav_3a_3aresourcelist"><code>HTTP::DAV::ResourceList</code></a> object. You can operate against all of the locks that you have created as follows:</p>
 
405
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
 
406
<p>When you lock a resource, the lock is held against the current HTTP::DAV object. In fact, the locks are held in a <a href="#http_dav_resourcelist"><code>HTTP::DAV::ResourceList</code></a> object. You can operate against all of the locks that you have created as follows:</p>
391
407
<pre>
392
408
  ## Print and unlock all locks that we own.
393
409
  my $rl_obj = $d-&gt;get_lockedresourcelist();
400
416
      ## Unlock them?
401
417
      $resource-&gt;unlock;
402
418
  }</pre>
403
 
<p>Typically, a simple $d-&gt;<a href="#item_unlock"><code>unlock($uri)</code></a> will suffice.</p>
 
419
<p>Typically, a simple $d-&gt;<a href="#unlock"><code>unlock($uri)</code></a> will suffice.</p>
404
420
<p><strong>lock example</strong></p>
405
421
<pre>
406
422
  $d-&gt;lock($uri, -timeout=&gt;&quot;1d&quot;);
408
424
  $d-&gt;put(&quot;/tmp/index.html&quot;,$uri);
409
425
  $d-&gt;unlock($uri);</pre>
410
426
</dd>
411
 
<dt><strong><a name="item_mkcol"><strong>mkcol(URL)</strong></a></strong></dt>
 
427
<dt><strong><a name="mkcol" class="item"><strong>mkcol(URL)</strong></a></strong></dt>
412
428
 
413
429
<dd>
414
430
<p>make a remote collection (directory)</p>
415
431
<p>The return value is always 1 or 0 indicating success or failure.</p>
416
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
 
432
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
417
433
<pre>
418
434
  $d-&gt;open(&quot;host.org/dav_dir/&quot;);
419
435
  $d-&gt;mkcol(&quot;new_dir&quot;);                  # Should succeed
420
436
  $d-&gt;mkcol(&quot;/dav_dir/new_dir&quot;);         # Should succeed
421
437
  $d-&gt;mkcol(&quot;/dav_dir/new_dir/xxx/yyy&quot;); # Should fail</pre>
422
438
</dd>
423
 
<dt><strong><a name="item_move"><strong>move(URL,DEST,[OVERWRITE],[DEPTH])</strong></a></strong></dt>
 
439
<dt><strong><a name="move" class="item"><strong>move(URL,DEST,[OVERWRITE],[DEPTH])</strong></a></strong></dt>
424
440
 
425
441
<dd>
426
442
<p>moves one remote resource to another</p>
427
443
<dl>
428
 
<dt><strong><code>-url</code></strong></dt>
 
444
<dt><strong><a name="url4" class="item"><a href="#url"><code>-url</code></a></a></strong></dt>
429
445
 
430
446
<dd>
431
447
<p>is the remote resource you'd like to move. Mandatory</p>
432
448
</dd>
433
 
<dt><strong><code>-dest</code></strong></dt>
 
449
<dt><strong><a name="dest2" class="item"><a href="#dest"><code>-dest</code></a></a></strong></dt>
434
450
 
435
451
<dd>
436
452
<p>is the remote target for the move command. Mandatory</p>
437
453
</dd>
438
 
<dt><strong><code>-overwrite</code></strong></dt>
 
454
<dt><strong><a name="overwrite2" class="item"><a href="#overwrite"><code>-overwrite</code></a></a></strong></dt>
439
455
 
440
456
<dd>
441
 
<p>optionally indicates whether the server should fail if the target exists. Valid values are ``T'' and ``F'' (1 and 0 are synonymous). Default is T.</p>
 
457
<p>optionally indicates whether the server should fail if the target exists. Valid values are &quot;T&quot; and &quot;F&quot; (1 and 0 are synonymous). Default is T.</p>
442
458
</dd>
443
459
</dl>
444
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
 
460
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
445
461
<p>The return value is always 1 or 0 indicating success or failure.</p>
446
462
<p>Note: if either <code>'URL'</code> or <code>'DEST'</code> are locked by this dav client, then the lock headers will be taken care of automatically. If either of the two URL's are locked by someone else, the server should reject the request.</p>
447
463
<p><strong>move examples:</strong></p>
461
477
<pre>
462
478
  $d-&gt;move(&quot;file.txt&quot;,&quot;/dav_dir/dir2/new_file.txt&quot;)</pre>
463
479
</dd>
464
 
<dt><strong><a name="item_open"><strong>open(URL)</strong></a></strong></dt>
 
480
<dt><strong><a name="open" class="item"><strong>open(URL)</strong></a></strong></dt>
465
481
 
466
482
<dd>
467
483
<p>opens the directory (collection resource) at URL.</p>
468
484
<p>open will perform a propfind against URL. If the server does not understand the request then the open will fail.</p>
469
485
<p>Similarly, if the server indicates that the resource at URL is NOT a collection, the open command will fail.</p>
470
486
</dd>
471
 
<dt><strong><a name="item_options"><strong>options([URL])</strong></a></strong></dt>
 
487
<dt><strong><a name="options" class="item"><strong>options([URL])</strong></a></strong></dt>
472
488
 
473
489
<dd>
474
490
<p>Performs an OPTIONS request against the URL or the working resource if URL is not supplied.</p>
475
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
 
491
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
476
492
<p>The return value is a string of comma separated OPTIONS that the server states are legal for URL or undef otherwise.</p>
477
493
<p>A fully compliant DAV server may offer as many methods as: OPTIONS, TRACE, GET, HEAD, DELETE, PUT, COPY, MOVE, PROPFIND, PROPPATCH, LOCK, UNLOCK</p>
478
494
<p>Note: IIS5 does not support PROPPATCH or LOCK on collections.</p>
489
505
    print &quot;OK to proppatch\n&quot;;
490
506
 }</pre>
491
507
</dd>
492
 
<dt><strong><a name="item_propfind"><strong>propfind([URL],[DEPTH])</strong></a></strong></dt>
 
508
<dt><strong><a name="propfind" class="item"><strong>propfind([URL],[DEPTH])</strong></a></strong></dt>
493
509
 
494
510
<dd>
495
511
<p>Perform a propfind against URL at DEPTH depth.</p>
496
 
<p><a href="#item__2ddepth"><code>-depth</code></a> can be used to specify how deep the propfind goes. ``0'' is collection only. ``1'' is collection and it's immediate members (This is the default value). ``infinity'' is the entire directory tree. Note that most DAV compliant servers deny ``infinity'' depth propfinds for security reasons.</p>
497
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
498
 
<p>The return value is an <a href="#item_http_3a_3adav_3a_3aresource"><code>HTTP::DAV::Resource</code></a> object on success or 0 on failure.</p>
 
512
<p><a href="#depth"><code>-depth</code></a> can be used to specify how deep the propfind goes. &quot;0&quot; is collection only. &quot;1&quot; is collection and it's immediate members (This is the default value). &quot;infinity&quot; is the entire directory tree. Note that most DAV compliant servers deny &quot;infinity&quot; depth propfinds for security reasons.</p>
 
513
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
 
514
<p>The return value is an <a href="#http_dav_resource"><code>HTTP::DAV::Resource</code></a> object on success or 0 on failure.</p>
499
515
<p>The Resource object can be used for interrogating properties or performing other operations.</p>
500
516
<pre>
501
517
 ## Print collection or content length
509
525
 }</pre>
510
526
<p>Please note that although you may set a different namespace for a property of a resource during a set_prop, HTTP::DAV currently ignores all XML namespaces so you will get clashes if two properties have the same name but in different namespaces. Currently this is unavoidable but I'm working on the solution.</p>
511
527
</dd>
512
 
<dt><strong><a name="item_proppatch"><strong>proppatch([URL],[NAMESPACE],PROPNAME,PROPVALUE,ACTION,[NSABBR])</strong></a></strong></dt>
 
528
<dt><strong><a name="proppatch" class="item"><strong>proppatch([URL],[NAMESPACE],PROPNAME,PROPVALUE,ACTION,[NSABBR])</strong></a></strong></dt>
513
529
 
514
530
<dd>
515
 
<p>If <code>-action</code> equals ``set'' then we set a property named <code>-propname</code> to <code>-propvalue</code> in the namespace <code>-namespace</code> for <a href="#item__2durl"><code>-url</code></a>.</p>
516
 
<p>If <code>-action</code> equals ``remove'' then we unset a property named <code>-propname</code> in the namespace <code>-namespace</code> for <a href="#item__2durl"><code>-url</code></a>.</p>
517
 
<p>If no action is supplied then the default action is ``set''.</p>
518
 
<p>The return value is an <a href="#item_http_3a_3adav_3a_3aresource"><code>HTTP::DAV::Resource</code></a> object on success or 0 on failure.</p>
 
531
<p>If <code>-action</code> equals &quot;set&quot; then we set a property named <code>-propname</code> to <code>-propvalue</code> in the namespace <code>-namespace</code> for <a href="#url"><code>-url</code></a>.</p>
 
532
<p>If <code>-action</code> equals &quot;remove&quot; then we unset a property named <code>-propname</code> in the namespace <code>-namespace</code> for <a href="#url"><code>-url</code></a>.</p>
 
533
<p>If no action is supplied then the default action is &quot;set&quot;.</p>
 
534
<p>The return value is an <a href="#http_dav_resource"><code>HTTP::DAV::Resource</code></a> object on success or 0 on failure.</p>
519
535
<p>The Resource object can be used for interrogating properties or performing other operations.</p>
520
536
<p>To explicitly set a namespace in which to set the propname then you can use the <code>-namespace</code> and <code>-nsabbr</code> (namespace abbreviation) parameters. But you're welcome to play around with DAV namespaces.</p>
521
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
522
 
<p>It is recommended that you use <a href="#item_set_prop"><code>set_prop</code></a> and <a href="#item_unset_prop"><code>unset_prop</code></a> instead of proppatch for readability.</p>
523
 
<p><a href="#item_set_prop"><code>set_prop</code></a> simply calls <a href="#item_proppatch"><code>proppatch(-action=</code></a>set)&gt; and <a href="#item_unset_prop"><code>unset_prop</code></a> calls <a href="#item_proppatch"><code>proppatch(-action=</code></a>``remove'')&gt;</p>
524
 
<p>See <a href="#item_set_prop"><code>set_prop</code></a> and <a href="#item_unset_prop"><code>unset_prop</code></a> for examples.</p>
 
537
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
 
538
<p>It is recommended that you use <a href="#set_prop"><code>set_prop</code></a> and <a href="#unset_prop"><code>unset_prop</code></a> instead of proppatch for readability.</p>
 
539
<p><a href="#set_prop"><code>set_prop</code></a> simply calls <a href="#proppatch"><code>proppatch(-action=</code></a>set)&gt; and <a href="#unset_prop"><code>unset_prop</code></a> calls <a href="#proppatch"><code>proppatch(-action=</code></a>&quot;remove&quot;)&gt;</p>
 
540
<p>See <a href="#set_prop"><code>set_prop</code></a> and <a href="#unset_prop"><code>unset_prop</code></a> for examples.</p>
525
541
</dd>
526
 
<dt><strong><a name="item_put"><strong>put(LOCAL,[URL],[CALLBACK])</strong></a></strong></dt>
 
542
<dt><strong><a name="put" class="item"><strong>put(LOCAL,[URL],[CALLBACK],[HEADERS])</strong></a></strong></dt>
527
543
 
528
544
<dd>
529
 
<p>uploads the files or directories at -local to the remote destination at -url.</p>
530
 
<p>-local points to a file, directory or series of files or directories (indicated by a glob).</p>
 
545
<p>uploads the files or directories at <code>-local</code> to the remote destination at <a href="#url"><code>-url</code></a>.</p>
 
546
<p><code>-local</code> points to a file, directory or series of files or directories (indicated by a glob).</p>
531
547
<p>If the filename contains any of the characters `*',  `?' or  `['  it is a candidate for filename substitution, also  known  as  ``globbing''.   This word  is  then regarded as a pattern (``glob-pattern''), and replaced with an alphabetically sorted list  of  file  names which match the pattern.</p>
532
548
<p>One can upload/put a string by passing a reference to a scalar in the -local parameter. See example below.</p>
533
 
<p>put requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
 
549
<p>put requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
534
550
<p>The return value is always 1 or 0 indicating success or failure.</p>
535
 
<p>See <a href="#item_get">get()</a> for a description of what the optional callback parameter does.</p>
 
551
<p>See <a href="#get">get()</a> for a description of what the optional callback parameter does.</p>
 
552
<p>You can also pass a <code>-headers</code> argument. That allows to specify custom HTTP headers. It can be either a hashref with header names and values, or a <a href="HTTP/Headers.html">the HTTP::Headers manpage</a> object.</p>
536
553
<p><strong>put examples:</strong></p>
537
554
<p>Put a string to the server:</p>
538
555
<pre>
550
567
  
551
568
  uploads file1.html, file1, file2.html, file2.txt and the directory file2/ to dav_dir/.</pre>
552
569
</dd>
553
 
<dt><strong><a name="item_set_prop"><strong>set_prop([URL],[NAMESPACE],PROPNAME,PROPVALUE)</strong></a></strong></dt>
 
570
<dt><strong><a name="set_prop" class="item"><strong>set_prop([URL],[NAMESPACE],PROPNAME,PROPVALUE)</strong></a></strong></dt>
554
571
 
555
572
<dd>
556
 
<p>Sets a property named <code>-propname</code> to <code>-propvalue</code> in the namespace <code>-namespace</code> for <a href="#item__2durl"><code>-url</code></a>.</p>
557
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
558
 
<p>The return value is an <a href="#item_http_3a_3adav_3a_3aresource"><code>HTTP::DAV::Resource</code></a> object on success or 0 on failure.</p>
 
573
<p>Sets a property named <code>-propname</code> to <code>-propvalue</code> in the namespace <code>-namespace</code> for <a href="#url"><code>-url</code></a>.</p>
 
574
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
 
575
<p>The return value is an <a href="#http_dav_resource"><code>HTTP::DAV::Resource</code></a> object on success or 0 on failure.</p>
559
576
<p>The Resource object can be used for interrogating properties or performing other operations.</p>
560
577
<p>Example:</p>
561
578
<pre>
570
587
 }</pre>
571
588
<p>See the note in propfind about namespace support in HTTP::DAV. They're settable, but not readable.</p>
572
589
</dd>
573
 
<dt><strong><a name="item_steal"><strong>steal([URL])</strong></a></strong></dt>
 
590
<dt><strong><a name="steal" class="item"><strong>steal([URL])</strong></a></strong></dt>
574
591
 
575
592
<dd>
576
593
<p>forcefully steals any locks held against URL.</p>
577
594
<p>steal will perform a propfind against URL and then, any locks that are found will be unlocked one by one regardless of whether we own them or not.</p>
578
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
 
595
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
579
596
<p>The return value is always 1 or 0 indicating success or failure. If multiple locks are found and unlocking one of them fails then the operation will be aborted.</p>
580
597
<pre>
581
598
 if ($d-&gt;steal()) {
584
601
    print &quot;Steal failed: &quot;. $d-&gt;message() . &quot;\n&quot;;
585
602
 }</pre>
586
603
</dd>
587
 
<dt><strong><a name="item_unlock"><strong>unlock([URL])</strong></a></strong></dt>
 
604
<dt><strong><a name="unlock" class="item"><strong>unlock([URL])</strong></a></strong></dt>
588
605
 
589
606
<dd>
590
607
<p>unlocks any of our locks on URL.</p>
591
 
<p>Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
 
608
<p>Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
592
609
<p>The return value is always 1 or 0 indicating success or failure.</p>
593
610
<pre>
594
611
 if ($d-&gt;unlock()) {
597
614
    print &quot;Unlock failed: &quot;. $d-&gt;message() . &quot;\n&quot;;
598
615
 }</pre>
599
616
</dd>
600
 
<dt><strong><a name="item_unset_prop"><strong>unset_prop([URL],[NAMESPACE],PROPNAME)</strong></a></strong></dt>
 
617
<dt><strong><a name="unset_prop" class="item"><strong>unset_prop([URL],[NAMESPACE],PROPNAME)</strong></a></strong></dt>
601
618
 
602
619
<dd>
603
 
<p>Unsets a property named <code>-propname</code> in the namespace <code>-namespace</code> for <a href="#item__2durl"><code>-url</code></a>. 
604
 
Requires a working resource to be set before being called. See <a href="#item_open"><code>open</code></a>.</p>
605
 
<p>The return value is an <a href="#item_http_3a_3adav_3a_3aresource"><code>HTTP::DAV::Resource</code></a> object on success or 0 on failure.</p>
 
620
<p>Unsets a property named <code>-propname</code> in the namespace <code>-namespace</code> for <a href="#url"><code>-url</code></a>. 
 
621
Requires a working resource to be set before being called. See <a href="#open"><code>open</code></a>.</p>
 
622
<p>The return value is an <a href="#http_dav_resource"><code>HTTP::DAV::Resource</code></a> object on success or 0 on failure.</p>
606
623
<p>The Resource object can be used for interrogating properties or performing other operations.</p>
607
624
<p>Example:</p>
608
625
<pre>
621
638
</p>
622
639
<h2><a name="accessor_methods">ACCESSOR METHODS</a></h2>
623
640
<dl>
624
 
<dt><strong><a name="item_get_user_agent"><strong>get_user_agent</strong></a></strong></dt>
 
641
<dt><strong><a name="get_user_agent" class="item"><strong>get_user_agent</strong></a></strong></dt>
625
642
 
626
643
<dd>
627
644
<p>Returns the clients' working <code>HTTP::DAV::UserAgent</code> object.</p>
629
646
to modify request headers or provide advanced authentication 
630
647
procedures. See dave for an advanced authentication procedure.</p>
631
648
</dd>
632
 
<dt><strong><a name="item_get_last_request"><strong>get_last_request</strong></a></strong></dt>
 
649
<dt><strong><a name="get_last_request" class="item"><strong>get_last_request</strong></a></strong></dt>
633
650
 
634
651
<dd>
635
 
<p>Takes no arguments and returns the clients' last outgoing <a href="#item_http_3a_3arequest"><code>HTTP::Request</code></a> object.</p>
 
652
<p>Takes no arguments and returns the clients' last outgoing <a href="#http_request"><code>HTTP::Request</code></a> object.</p>
636
653
<p>You would only use this to inspect a request that has already occurred.</p>
637
 
<p>If you would like to modify the <a href="#item_http_3a_3arequest"><code>HTTP::Request</code></a> BEFORE the HTTP request takes place (for instance to add another header), you will need to get the <code>HTTP::DAV::UserAgent</code> using <a href="#item_get_user_agent"><code>get_user_agent</code></a> and interact with that.</p>
 
654
<p>If you would like to modify the <a href="#http_request"><code>HTTP::Request</code></a> BEFORE the HTTP request takes place (for instance to add another header), you will need to get the <code>HTTP::DAV::UserAgent</code> using <a href="#get_user_agent"><code>get_user_agent</code></a> and interact with that.</p>
638
655
</dd>
639
 
<dt><strong><a name="item_get_workingresource"><strong>get_workingresource</strong></a></strong></dt>
 
656
<dt><strong><a name="get_workingresource" class="item"><strong>get_workingresource</strong></a></strong></dt>
640
657
 
641
658
<dd>
642
 
<p>Returns the currently ``opened'' or ``working'' resource (<a href="#item_http_3a_3adav_3a_3aresource"><code>HTTP::DAV::Resource</code></a>).</p>
 
659
<p>Returns the currently &quot;opened&quot; or &quot;working&quot; resource (<a href="#http_dav_resource"><code>HTTP::DAV::Resource</code></a>).</p>
643
660
<p>The working resource is changed whenever you open a url or use the cwd command.</p>
644
661
<p>e.g. 
645
662
  $r = $d-&gt;get_workingresource
646
 
  print ``pwd: '' . $r-&gt;get_uri . ``\n'';</p>
 
663
  print &quot;pwd: &quot; . $r-&gt;get_uri . &quot;\n&quot;;</p>
647
664
</dd>
648
 
<dt><strong><a name="item_get_workingurl"><strong>get_workingurl</strong></a></strong></dt>
 
665
<dt><strong><a name="get_workingurl" class="item"><strong>get_workingurl</strong></a></strong></dt>
649
666
 
650
667
<dd>
651
 
<p>Returns the currently ``opened'' or ``working'' <code>URL</code>.</p>
 
668
<p>Returns the currently &quot;opened&quot; or &quot;working&quot; <code>URL</code>.</p>
652
669
<p>The working resource is changed whenever you open a url or use the cwd command.</p>
653
670
<pre>
654
671
  print &quot;pwd: &quot; . $d-&gt;get_workingurl . &quot;\n&quot;;</pre>
655
672
</dd>
656
 
<dt><strong><a name="item_get_lockedresourcelist"><strong>get_lockedresourcelist</strong></a></strong></dt>
 
673
<dt><strong><a name="get_lockedresourcelist" class="item"><strong>get_lockedresourcelist</strong></a></strong></dt>
657
674
 
658
675
<dd>
659
 
<p>Returns an <a href="#item_http_3a_3adav_3a_3aresourcelist"><code>HTTP::DAV::ResourceList</code></a> object that represents all of the locks we've created using THIS dav client.</p>
 
676
<p>Returns an <a href="#http_dav_resourcelist"><code>HTTP::DAV::ResourceList</code></a> object that represents all of the locks we've created using THIS dav client.</p>
660
677
<pre>
661
678
  print &quot;pwd: &quot; . $d-&gt;get_workingurl . &quot;\n&quot;;</pre>
662
679
</dd>
663
 
<dt><strong><a name="item_get_absolute_uri"><strong>get_absolute_uri(REL_URI,[BASE_URI])</strong></a></strong></dt>
 
680
<dt><strong><a name="get_absolute_uri" class="item"><strong>get_absolute_uri(REL_URI,[BASE_URI])</strong></a></strong></dt>
664
681
 
665
682
<dd>
666
683
<p>This is a useful utility function which joins <code>BASE_URI</code> and <code>REL_URI</code> and returns a new URI.</p>
667
684
<p>If <code>BASE_URI</code> is not supplied then the current working resource (as indicated by get_workingurl) is used. If <code>BASE_URI</code> is not set and there is no current working resource the <code>REL_URI</code> will be returned.</p>
668
685
<p>For instance:
669
 
 $d-&gt;open(``http://host.org/webdav/dir1/'');</p>
 
686
 $d-&gt;open(&quot;http://host.org/webdav/dir1/&quot;);</p>
670
687
<pre>
671
688
 # Returns &quot;<a href="http://host.org/webdav/dir2/&quot">http://host.org/webdav/dir2/&quot</a>;
672
689
 $d-&gt;get_absolute_uri(-rel_uri=&gt;&quot;../dir2&quot;);</pre>
681
698
</p>
682
699
<h2><a name="error_handling_methods">ERROR HANDLING METHODS</a></h2>
683
700
<dl>
684
 
<dt><strong><a name="item_message"><strong>message</strong></a></strong></dt>
 
701
<dt><strong><a name="message" class="item"><strong>message</strong></a></strong></dt>
685
702
 
686
703
<dd>
687
 
<p><a href="#item_message"><code>message</code></a> gets the last success or error message.</p>
 
704
<p><a href="#message"><code>message</code></a> gets the last success or error message.</p>
688
705
<p>The return value is always a scalar (string) and will change everytime a dav operation is invoked (lock, cwd, put, etc).</p>
689
 
<p>See also <a href="#item_errors"><code>errors</code></a> for operations which contain multiple error messages.</p>
 
706
<p>See also <a href="#errors"><code>errors</code></a> for operations which contain multiple error messages.</p>
690
707
</dd>
691
 
<dt><strong><a name="item_errors"><strong>errors</strong></a></strong></dt>
 
708
<dt><strong><a name="errors" class="item"><strong>errors</strong></a></strong></dt>
692
709
 
693
710
<dd>
694
711
<p>Returns an @array of error messages that had been set during a multi-request operation.</p>
695
712
<p>Some of <code>HTTP::DAV</code>'s operations perform multiple request to the server. At the time of writing only put and get are considered multi-request since they can operate recursively requiring many HTTP requests.</p>
696
713
<p>In these situations you should check the errors array if to determine if any of the requests failed.</p>
697
 
<p>The <a href="#item_errors"><code>errors</code></a> function is used for multi-request operations and not to be confused with a multi-status server response. A multi-status server response is when the server responds with multiple error messages for a SINGLE request. To deal with multi-status responses, see <a href="#item_http_3a_3adav_3a_3aresponse"><code>HTTP::DAV::Response</code></a>.</p>
 
714
<p>The <a href="#errors"><code>errors</code></a> function is used for multi-request operations and not to be confused with a multi-status server response. A multi-status server response is when the server responds with multiple error messages for a SINGLE request. To deal with multi-status responses, see <a href="#http_dav_response"><code>HTTP::DAV::Response</code></a>.</p>
698
715
<pre>
699
716
 # Recursive put
700
717
 if (!$d-&gt;put( &quot;/tmp/my_dir&quot;, $url ) ) {
704
721
    foreach $err ( $d-&gt;errors ) { print &quot;  Error:$err\n&quot; }
705
722
 }</pre>
706
723
</dd>
707
 
<dt><strong><a name="item_is_success"><strong>is_success</strong></a></strong></dt>
 
724
<dt><strong><a name="is_success" class="item"><strong>is_success</strong></a></strong></dt>
708
725
 
709
726
<dd>
710
727
<p>Returns the status of the last DAV operation performed through the HTTP::DAV interface.</p>
713
730
  # This will always evaluate to true
714
731
  ($d-&gt;lock($url) eq $d-&gt;is_success) ?</pre>
715
732
<p>You may want to use the is_success method if you didn't capture the return value immediately. But in most circumstances you're better off just evaluating as follows:
716
 
  if($d-&gt;<a href="#item_lock"><code>lock($url))</code></a> { ... }</p>
 
733
  if($d-&gt;lock($url)) { ... }</p>
717
734
</dd>
718
 
<dt><strong><a name="item_get_lastresponse"><strong>get_lastresponse</strong></a></strong></dt>
 
735
<dt><strong><a name="get_last_response" class="item"><strong>get_last_response</strong></a></strong></dt>
719
736
 
720
737
<dd>
721
 
<p>Takes no arguments and returns the last seen <a href="#item_http_3a_3adav_3a_3aresponse"><code>HTTP::DAV::Response</code></a> object.</p>
 
738
<p>Takes no arguments and returns the last seen <a href="#http_dav_response"><code>HTTP::DAV::Response</code></a> object.</p>
722
739
<p>You may want to use this if you have just called a propfind and need the individual error messages returned in a MultiStatus.</p>
723
 
<p>If you find that you're using <code>get_last_response()</code> method a lot, you may be better off using the more advanced <code>HTTP::DAV</code> interface and interacting with the HTTP::DAV::* interfaces directly as discussed in the intro. For instance, if you find that you're always wanting a detailed understanding of the server's response headers or messages, then you're probably better off using the <a href="#item_http_3a_3adav_3a_3aresource"><code>HTTP::DAV::Resource</code></a> methods and interpreting the <a href="#item_http_3a_3adav_3a_3aresponse"><code>HTTP::DAV::Response</code></a> directly.</p>
724
 
<p>To perform detailed analysis of the server's response (if for instance you got back a multistatus response) you can call get_lastresponse which will return to you the most recent response object (always the result of the last operation, PUT, PROPFIND, etc). With the returned HTTP::DAV::Response object you can handle multi-status responses.</p>
 
740
<p>If you find that you're using <a href="#get_last_response"><code>get_last_response()</code></a> method a lot, you may be better off using the more advanced <code>HTTP::DAV</code> interface and interacting with the HTTP::DAV::* interfaces directly as discussed in the intro. For instance, if you find that you're always wanting a detailed understanding of the server's response headers or messages, then you're probably better off using the <a href="#http_dav_resource"><code>HTTP::DAV::Resource</code></a> methods and interpreting the <a href="#http_dav_response"><code>HTTP::DAV::Response</code></a> directly.</p>
 
741
<p>To perform detailed analysis of the server's response (if for instance you got back a multistatus response) you can call <a href="#get_last_response"><code>get_last_response()</code></a> which will return to you the most recent response object (always the result of the last operation, PUT, PROPFIND, etc). With the returned HTTP::DAV::Response object you can handle multi-status responses.</p>
725
742
<p>For example:</p>
726
743
<pre>
727
744
   # Print all of the messages in a multistatus response
728
745
   if (! $d-&gt;unlock($url) ) {
729
 
      $response = $d-&gt;get_lastresponse();
 
746
      $response = $d-&gt;get_last_response();
730
747
      if ($response-&gt;is_multistatus() ) {
731
748
        foreach $num ( 0 .. $response-&gt;response_count() ) {
732
749
           ($err_code,$mesg,$url,$desc) =
741
758
</p>
742
759
<h2><a name="advanced_methods">ADVANCED METHODS</a></h2>
743
760
<dl>
744
 
<dt><strong><a name="item_new_resource"><strong>new_resource</strong></a></strong></dt>
 
761
<dt><strong><a name="new_resource" class="item"><strong>new_resource</strong></a></strong></dt>
745
762
 
746
763
<dd>
747
764
<p>Creates a new resource object with which to play.
748
 
This is the preferred way of creating an <a href="#item_http_3a_3adav_3a_3aresource"><code>HTTP::DAV::Resource</code></a> object if required.
 
765
This is the preferred way of creating an <a href="#http_dav_resource"><code>HTTP::DAV::Resource</code></a> object if required.
749
766
Why? Because each Resource object needs to sit within a global HTTP::DAV client. 
750
767
Also, because the new_resource routine checks the <code>HTTP::DAV</code> locked resource
751
768
list before creating a new object.</p>
752
769
<pre>
753
770
    $dav-&gt;new_resource( -uri =&gt; &quot;<a href="http://...&quot">http://...&quot</a>; );</pre>
754
771
</dd>
755
 
<dt><strong><a name="item_set_workingresource"><strong>set_workingresource(URL)</strong></a></strong></dt>
 
772
<dt><strong><a name="set_workingresource" class="item"><strong>set_workingresource(URL)</strong></a></strong></dt>
756
773
 
757
774
<dd>
758
775
<p>Sets the current working resource to URL.</p>
759
776
<p>You shouldn't need this method. Call open or cwd to set the working resource.</p>
760
 
<p>You CAN call <a href="#item_set_workingresource"><code>set_workingresource()</code></a> but you will need to perform a
761
 
<a href="#item_propfind"><code>propfind</code></a> immediately following it to ensure that the working
 
777
<p>You CAN call <a href="#set_workingresource"><code>set_workingresource()</code></a> but you will need to perform a
 
778
<a href="#propfind"><code>propfind</code></a> immediately following it to ensure that the working
762
779
resource is valid.</p>
763
780
</dd>
764
781
</dl>
766
783
</p>
767
784
<hr />
768
785
<h1><a name="installation__todo__mailing_lists_and_revision_history">INSTALLATION, TODO, MAILING LISTS and REVISION HISTORY</a></h1>
 
786
<p>[OUTDATED]</p>
769
787
<p>Please see the primary HTTP::DAV webpage at
770
788
(http://www.webdav.org/perldav/http-dav/)
771
789
or the README file in this library.</p>
775
793
<h1><a name="see_also">SEE ALSO</a></h1>
776
794
<p>You'll want to also read:</p>
777
795
<dl>
778
 
<dt><strong><a name="item_http_3a_3adav_3a_3aresponse"><code>HTTP::DAV::Response</code></a></strong></dt>
779
 
 
780
 
<dt><strong><a name="item_http_3a_3adav_3a_3aresource"><code>HTTP::DAV::Resource</code></a></strong></dt>
781
 
 
782
 
<dt><strong><a name="item_dave"><code>dave</code></a></strong></dt>
 
796
<dt><strong><a name="http_dav_response" class="item"><code>HTTP::DAV::Response</code></a></strong></dt>
 
797
 
 
798
<dt><strong><a name="http_dav_resource" class="item"><code>HTTP::DAV::Resource</code></a></strong></dt>
 
799
 
 
800
<dt><strong><a name="dave" class="item"><code>dave</code></a></strong></dt>
783
801
 
784
802
</dl>
785
803
<p>and maybe if you're more inquisitive:</p>
786
804
<dl>
787
 
<dt><strong><a name="item_lwp_3a_3auseragent"><code>LWP::UserAgent</code></a></strong></dt>
788
 
 
789
 
<dt><strong><a name="item_http_3a_3arequest"><code>HTTP::Request</code></a></strong></dt>
790
 
 
791
 
<dt><strong><a name="item_http_3a_3adav_3a_3acomms"><code>HTTP::DAV::Comms</code></a></strong></dt>
792
 
 
793
 
<dt><strong><a name="item_http_3a_3adav_3a_3alock"><code>HTTP::DAV::Lock</code></a></strong></dt>
794
 
 
795
 
<dt><strong><a name="item_http_3a_3adav_3a_3aresourcelist"><code>HTTP::DAV::ResourceList</code></a></strong></dt>
796
 
 
797
 
<dt><strong><a name="item_http_3a_3adav_3a_3autils"><code>HTTP::DAV::Utils</code></a></strong></dt>
 
805
<dt><strong><a name="lwp_useragent" class="item"><code>LWP::UserAgent</code></a></strong></dt>
 
806
 
 
807
<dt><strong><a name="http_request" class="item"><code>HTTP::Request</code></a></strong></dt>
 
808
 
 
809
<dt><strong><a name="http_dav_comms" class="item"><code>HTTP::DAV::Comms</code></a></strong></dt>
 
810
 
 
811
<dt><strong><a name="http_dav_lock" class="item"><code>HTTP::DAV::Lock</code></a></strong></dt>
 
812
 
 
813
<dt><strong><a name="http_dav_resourcelist" class="item"><code>HTTP::DAV::ResourceList</code></a></strong></dt>
 
814
 
 
815
<dt><strong><a name="http_dav_utils" class="item"><code>HTTP::DAV::Utils</code></a></strong></dt>
798
816
 
799
817
</dl>
800
818
<p>
810
828
    Email: pcollins@cpan.org
811
829
    Phone: +61 2 9663 4916</pre>
812
830
<p>All rights reserved.</p>
813
 
<p>Current co-maintainer of the module is Opera Software ASA,
814
 
<em><a href="mailto:opera@cpan.org">opera@cpan.org</a></em>.</p>
 
831
<p>Current co-maintainer of the module is Cosimo Streppone
 
832
for Opera Software ASA, <em><a href="mailto:opera@cpan.org">opera@cpan.org</a></em>.</p>
815
833
<p>You may distribute this module under the terms of either the
816
834
GNU General Public License or the Artistic License,
817
835
as specified in the Perl README file.</p>