Function: url-dav-process-response

url-dav-process-response is a byte-compiled function defined in url-dav.el.gz.

Signature

(url-dav-process-response BUFFER URL)

Documentation

Parse a WebDAV response from BUFFER, interpreting it relative to URL.

The buffer must have been retrieved by HTTP or HTTPS and contain an XML document.

Source Code

;; Defined in /usr/src/emacs/lisp/url/url-dav.el.gz
;;; DAV request/response generation/processing
(defun url-dav-process-response (buffer url)
  "Parse a WebDAV response from BUFFER, interpreting it relative to URL.

The buffer must have been retrieved by HTTP or HTTPS and contain an
XML document."
  (let ((tree nil)
	(overall-status nil))
    (when buffer
      (unwind-protect
	  (with-current-buffer buffer
	    ;; First remove all indentation and line endings
	    (goto-char url-http-end-of-headers)
	    (indent-rigidly (point) (point-max) -1000)
	    (save-excursion
	      (while (re-search-forward "\r?\n" nil t)
		(replace-match "")))
	    (setq overall-status url-http-response-status)

	    ;; XML documents can be transferred as either text/xml or
	    ;; application/xml, and we are required to accept both of
	    ;; them.
	    (if (and
		 url-http-content-type
		 (string-match "\\`\\(text\\|application\\)/xml"
			       url-http-content-type))
		(setq tree (xml-parse-region (point) (point-max) nil nil 'symbol-qnames))))
	;; Clean up after ourselves.
	(kill-buffer buffer)))

    ;; We should now be
    (if (eq (xml-node-name (car tree)) 'DAV:multistatus)
	(url-dav-dispatch-node (car tree))
      (url-debug 'dav "Got back singleton response for URL(%S)" url)
      (let ((properties (url-dav-dispatch-node (car tree))))
	;; We need to make sure we have a DAV:status node in there for
	;; higher-level code;
	(setq properties (plist-put properties 'DAV:status overall-status))
	;; Make this look like a DAV:multistatus parse tree so that
	;; nobody but us needs to know the difference.
	(list (cons url properties))))))