Plasma GitLab Archive
Projects Blog Knowledge

Module Webdav_client_methods

module Webdav_client_methods: sig .. end
Extension of the Http_client module for submitting WebDAV requests. See RFC 4918 (http://www.ietf.org/rfc/rfc4918.txt)

This definition is incomplete.

Strings are encoded in UTF-8, except where something else is specified. URLs are ASCII.

This module allows it to create method objects that can be passed to HTTP pipelines, e.g.

     let http = new Http_client.pipeline
     
     let propfind_cl = new propfind "http://server/"

     http # add (propfind_cl :> Http_client.http_call);
     http # run();

     (* now look at propfind_cl for response *)
   

Note that the method objects need to be coerced to http_call before being passed to the pipeline. There is no way of coercing them back, so users should keep the object propfind with the original type.



Success codes



WebDAV error reporting is complicated: File system conditions are mapped to the HTTP response status codes, which is looks rather weird. Also, many operations can return multistatus responses, with detailed status codes for each affected URL or even each property.
type call_status = [ `Client_error
| `Http_protocol_error of exn
| `Multi_status
| `Redirection
| `Server_error
| `Successful
| `Unserved ]
Condensed status information of a WebDAV call:
  • `Unserved: The call has not yet been finished
  • `HTTP_protocol_error e: An error on HTTP level occurred. Corresponds to the exception Http_client.Http_protocol.
  • `Successful: The call is successful, and the response code is between 200 and 299 (except 207 which is special, see below).
  • `Redirection: The call is successful, and the response code is between 300 and 399.
  • `Client_error: The call failed with a response code between 400 and 499.
  • `Server_error: The call failed for any other reason.
  • `Multi_status: The server responded with a 207 code. For PROPFIND and PROPPATCH the multistatus response includes detailed data about properties. For other methods the multistatus response means that for some URL the operation ran into an error but for other URLs it was successful. The classes defined below have methods to further analyze the situation (especially good_urls and bad_urls).

val string_of_call_status : call_status -> string

General types and values


type property = Webdav_xml.property 
A property is an XML tree. See Webdav_xml.property for more information
type prepost_code = Webdav_xml.prepost_code 
A precondition/postcondition element. Works in the same way as property.
class type propstat_t = object .. end
Information about individual properties
class type response_t = object .. end
Information about the response status per path
class type webdav_call_t = object .. end
A WebDAV call is a request with response

URL construction


val url_append : string -> string -> string
url_append base path: Appends the path to the URL base, and returns the new URL. Here, base must be a properly encoded URL, with http://server prefix. path is a normal slash-separated path without special escaping. The return value is again an absolute URL.

The path must be absolute (begins with "/").

Examples:

  • url_append "http://server" "/dir/file" = "http://server/dir/file"
  • url_append "http://server/dir" "/file" = "http://server/dir/file"
  • url_append "http://server" "/a file" = "http://server/a%20file"


PROPFIND


type propfind_request = [ `Allprop of property list
| `Prop of property list
| `Propname ]
What is requested:
  • `Prop l: Request the properties listed in l (which must be non-empty). The nodes in l are XML elements without children.
  • `Propname: Request a list of property names
  • `Allprop l: Request all properties, and include especially the extension properties l (which may be empty). In l one can request additional properties of the WebDAV namespace that are not defined in RFC 4918.

val propname_creationdate : property
val propname_displayname : property
val propname_getcontentlanguage : property
val propname_getcontentlength : property
val propname_getcontenttype : property
val propname_getetag : property
val propname_getlastmodified : property
val propname_resourcetype : property
Standard WebDAV properties. These objects can be included in `Prop requests. These properties should be returned anyway for `Allprop [].
class type propfind_call_t = webdav_call_t
class propfind_call : propfind_call_t
Creates a request object for PROPFIND.
class propfind : ?depth:Webdav_http.depth -> ?propfind_request:propfind_request -> ?strip_prefix:string -> string -> propfind_call_t
new propfind url: Creates a PROPFIND request.

Simplified interface for getting file listings
type list_request = [ `Existence | `Standard ] 
`Existence means a list request where only the resourcetype property is queried - useful for finding out which files exist. `Standard includes all standard properties.
class type filelist_t = propfind_call_t
In order to get property values, look up the per-URL response with response_of_url, and then call one of the prop_* methods, e.g.
class filelist : ?depth:Webdav_http.depth -> ?strip_prefix:string -> list_request -> string -> filelist_t
let l = new filelist req url: Creates a new request object for retrieving file listings.

PROPPATCH


type proppatch_instruction = [ `Remove of property list
| `Set of property list ]
Which properties to modify:
  • `Remove props: Removes the properties props. The list props should only contain the property names with empty contents
  • `Set props: Sets the properties props. The list props must include properties that include contents. One can create such properties with the encode_* functions in Webdav_xml.

type proppatch_request = proppatch_instruction list 
The property updates are executed in order. The updates are either all executed, or none is executed
class type proppatch_call_t = webdav_call_t
class proppatch_call : propfind_call_t
Creates a request object for PROPPATCH.
class proppatch : ?strip_prefix:string -> proppatch_request:proppatch_request -> string -> propfind_call_t
new proppatch ~proppatch_request url: Creates a PROPPATCH request.

MKCOL



MKCOL creates collections (directories)
class type mkcol_call_t = webdav_call_t
class mkcol_call : mkcol_call_t
Creates a request object for MKCOL.
class mkcol : ?strip_prefix:string -> string -> mkcol_call_t
new mkcol uri: Creates a new collection at uri.

GET



GET requests a document
class type get_call_t = webdav_call_t
class get_call : get_call_t
Creates a request object for GET.
class get : ?strip_prefix:string -> string -> get_call_t
new get uri: Gets the document at uri.

DELETE



DELETE collections and documents
class type delete_call_t = webdav_call_t
class delete_call : delete_call_t
Creates a request object for DELETE.
class delete : ?strip_prefix:string -> string -> delete_call_t
new delete uri: Deletes the document or collection at uri.

PUT



Add/replace documents
class type put_call_t = webdav_call_t
class put_call : put_call_t
Creates a request object for PUT.
class put : ?content_type:string -> ?content_length:int64 -> ?expect_handshake:bool -> ?strip_prefix:string -> string -> Netmime.mime_body -> put_call_t
new put url body: Uploads the contents of body to the server so it will be visible at url.

COPY



Copy documents, collections, or subtrees
class type copy_call_t = webdav_call_t
class copy_call : copy_call_t
Creates a request object for COPY.
class copy : ?depth:Webdav_http.depth -> ?overwrite:bool -> ?strip_prefix:string -> string -> string -> copy_call_t
new copy src_url dest_url: Copies the object(s) at src_url so that they become visible at dest_url.

MOVE



Move documents, collections, or subtrees
class type move_call_t = webdav_call_t
class move_call : copy_call_t
Creates a request object for MOVE.
class move : ?overwrite:bool -> ?strip_prefix:string -> string -> string -> move_call_t
new move src_url dest_url: Moves the object(s) at src_url so that they become visible at dest_url.
This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml