Function: url-dav-request
url-dav-request is an autoloaded and byte-compiled function defined in
url-dav.el.gz.
Signature
(url-dav-request URL METHOD TAG BODY &optional DEPTH HEADERS NAMESPACES)
Documentation
Perform WebDAV operation METHOD on URL. Return the parsed responses.
Automatically creates an XML request body if TAG is non-nil. BODY is the XML document fragment to be enclosed by <TAG></TAG>.
DEPTH is how deep the request should propagate. Default is 0, meaning
it should apply only to URL. A negative number means to use
Infinity for the depth. Not all WebDAV servers support this depth
though.
HEADERS is an assoc list of extra headers to send in the request.
NAMESPACES is an assoc list of (NAMESPACE . EXPANSION), and these are added to the <TAG> element. The DAV=DAV: namespace is automatically added to this list, so most requests can just pass in nil.
Source Code
;; Defined in /usr/src/emacs/lisp/url/url-dav.el.gz
;;;###autoload
(defun url-dav-request (url method tag body
&optional depth headers namespaces)
"Perform WebDAV operation METHOD on URL. Return the parsed responses.
Automatically creates an XML request body if TAG is non-nil.
BODY is the XML document fragment to be enclosed by <TAG></TAG>.
DEPTH is how deep the request should propagate. Default is 0, meaning
it should apply only to URL. A negative number means to use
`Infinity' for the depth. Not all WebDAV servers support this depth
though.
HEADERS is an assoc list of extra headers to send in the request.
NAMESPACES is an assoc list of (NAMESPACE . EXPANSION), and these are
added to the <TAG> element. The DAV=DAV: namespace is automatically
added to this list, so most requests can just pass in nil."
;; Take care of the default value for depth...
(setq depth (or depth 0))
;; Now let's translate it into something webdav can understand.
(if (< depth 0)
(setq depth "Infinity")
(setq depth (int-to-string depth)))
(if (not (assoc "DAV" namespaces))
(setq namespaces (cons '("DAV" . "DAV:") namespaces)))
(let* ((url-request-extra-headers `(("Depth" . ,depth)
("Content-type" . "text/xml")
,@headers))
(url-request-method method)
(url-request-data
(if tag
(concat
"<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n"
"<" (symbol-name tag) " "
;; add in the appropriate namespaces...
(mapconcat (lambda (ns)
(concat "xmlns:" (car ns) "='" (cdr ns) "'"))
namespaces "\n ")
">\n"
body
"</" (symbol-name tag) ">\n"))))
(url-dav-process-response (url-retrieve-synchronously url) url)))