Liking cljdoc? Tell your friends :D

dk.simongray.webdav

A WebDAV client whose requests are plain maps, by RFC 4918, with the conditional requests of RFC 9110 and the Prefer header of RFC 8144.

Make a request map with request, send it with wary-fetch or any HTTP client, and read the response with parse-response, or do both with call!. A response is data whatever its status, so nothing throws for a 412 or a 404.

Property names are keywords, e.g. :dav/getetag, by a :namespaces table of URI to alias over xml/default-namespaces (see the xml namespace). A resource map has the same keys as the resource maps of the server's backend.

A WebDAV client whose requests are plain maps, by RFC 4918, with the
conditional requests of RFC 9110 and the Prefer header of RFC 8144.

Make a request map with request, send it with wary-fetch or any HTTP
client, and read the response with parse-response, or do both with
call!. A response is data whatever its status, so nothing throws for a
412 or a 404.

Property names are keywords, e.g. :dav/getetag, by a :namespaces table
of URI to alias over xml/default-namespaces (see the xml namespace).
A resource map has the same keys as the resource maps of the server's
backend.
raw docstring

call!clj/s

(call! request)
(call! request {:keys [send] :or {send http/send!} :as opts})

Send the request and return what parse-response says of the response (or in ClojureScript a promise of it), with the opts below:

  • :send, a function that sends a request map, in place of wary-fetch's send!

A request that reaches no server throws as wary-fetch's send! does.

Send the `request` and return what parse-response says of the response
(or in ClojureScript a promise of it), with the `opts` below:

- :send, a function that sends a request map, in place of wary-fetch's
  send!

A request that reaches no server throws as wary-fetch's send! does.
sourceraw docstring

parse-responseclj/s

(parse-response {:keys [method url namespaces] :as request}
                {:keys [status headers] :as response})

What the response (a map of :status, :headers and :body, as wary-fetch gives it) to the request says.

It always has the :status, and the :etag when the response has one. Then by the status and the method:

  • 207: the :resources, as resource returns them, e.g. of a PROPFIND or of the members that a COPY or a DELETE couldn't change, or :malformed? true when the body can't be read
  • a success of OPTIONS: the :dav classes and the :allow methods
  • a success of LOCK: the :lock that it took or refreshed, as resource gives its :locks
  • a success of GET or HEAD: the :content-type, :content-length and :last-modified, and the :body of a GET, with the :content-range of a part (a map of :start, :end and :total)
  • an error with a DAV:error body: the precondition names as :error, e.g. [:dav/propfind-finite-depth]
What the `response` (a map of :status, :headers and :body, as
wary-fetch gives it) to the `request` says.

It always has the :status, and the :etag when the response has one.
Then by the status and the method:

- 207: the :resources, as resource returns them, e.g. of a PROPFIND or
  of the members that a COPY or a DELETE couldn't change, or :malformed?
  true when the body can't be read
- a success of OPTIONS: the :dav classes and the :allow methods
- a success of LOCK: the :lock that it took or refreshed, as resource
  gives its :locks
- a success of GET or HEAD: the :content-type, :content-length and
  :last-modified, and the :body of a GET, with the :content-range of a
  part (a map of :start, :end and :total)
- an error with a DAV:error body: the precondition names as :error,
  e.g. [:dav/propfind-finite-depth]
sourceraw docstring

requestclj/s

(request method url)
(request method url {:keys [namespaces body as] :as opts})

The request map of the method, e.g. :propfind, to the url, with the opts below. Any method works, e.g. a :report of CalDAV.

Every request takes these options:

  • :credentials, a :username and a :password, or a :token, as a map or a function of no arguments that returns one
  • :headers, more headers
  • :depth, 0, 1 or :infinity
  • :if-match and :if-none-match, an ETag or *
  • :if, an If header, as text or as conditions/parse-if returns it
  • :minimal?, true to prefer a minimal answer (RFC 8144)
  • :lock-token, the token of a lock that the request holds, which goes in an If header of its own
  • :namespaces, the aliases of namespaces in property names
  • :body, the body of a method without options of its own, e.g. :report
  • the options of wary-fetch's send!, e.g. :timeout-seconds

Some methods take more:

  • :propfind, at :depth 0 unless given, takes :props, the names of the properties to get, or :propname? true for the names alone. Without them it asks for allprop and the names of :include.

  • :proppatch takes :patch, the operations in order: [:set name value] or [:set element] and [:remove name].

  • :put takes the :body, text or bytes, and its :content-type.

  • :copy and :move take the :destination, a URL or a path relative to url, and :overwrite? false to fail when it exists. A :copy takes :depth 0 for a collection alone.

  • :get takes :as :bytes for a body of bytes, and a :range of the first and the last byte to get (nil for the rest), as wary-fetch's send! takes it.

  • :lock takes the :scope (:exclusive or :shared) and the :owner (text or an element) of a new lock, and its :timeout in seconds or :infinite. Without a :scope it refreshes the lock of its :lock-token.

  • :unlock takes the :lock-token of the lock to remove.

    (request :propfind "https://dav.example.org/notes/" {:depth 1 :props [:dav/getetag :dav/resourcetype]})

The request map of the `method`, e.g. :propfind, to the `url`, with the
`opts` below. Any method works, e.g. a :report of CalDAV.

Every request takes these options:

- :credentials, a :username and a :password, or a :token, as a map or a
  function of no arguments that returns one
- :headers, more headers
- :depth, 0, 1 or :infinity
- :if-match and :if-none-match, an ETag or *
- :if, an If header, as text or as conditions/parse-if returns it
- :minimal?, true to prefer a minimal answer (RFC 8144)
- :lock-token, the token of a lock that the request holds, which goes
  in an If header of its own
- :namespaces, the aliases of namespaces in property names
- :body, the body of a method without options of its own, e.g. :report
- the options of wary-fetch's send!, e.g. :timeout-seconds

Some methods take more:

- :propfind, at :depth 0 unless given, takes :props, the names of the
  properties to get, or :propname? true for the names alone. Without
  them it asks for allprop and the names of :include.
- :proppatch takes :patch, the operations in order: [:set name value]
  or [:set element] and [:remove name].
- :put takes the :body, text or bytes, and its :content-type.
- :copy and :move take the :destination, a URL or a path relative to
  `url`, and :overwrite? false to fail when it exists. A :copy takes
  :depth 0 for a collection alone.
- :get takes :as :bytes for a body of bytes, and a :range of the first
  and the last byte to get (nil for the rest), as wary-fetch's send!
  takes it.
- :lock takes the :scope (:exclusive or :shared) and the :owner (text
  or an element) of a new lock, and its :timeout in seconds or
  :infinite. Without a :scope it refreshes the lock of its
  :lock-token.
- :unlock takes the :lock-token of the lock to remove.

    (request :propfind "https://dav.example.org/notes/"
             {:depth 1 :props [:dav/getetag :dav/resourcetype]})
sourceraw docstring

resourceclj/s

(resource url {:keys [href status propstats error] :as response})

The resource map of a response of a multistatus, as xml/read-multistatus returns it, to a request of url. It has:

  • :href as the server wrote it, and :url, resolved against url, when it's on the same origin, since a request to it would carry the same credentials
  • :name, the decoded last segment, when it can name a file, so not e.g. ../x
  • :props, the values of the properties that came back with a success, by name, as xml/value gives them
  • :failed, the status of each property that didn't, by name, e.g. 404 for one that isn't there
  • :status and :error, when the response has them
  • :collection?, :etag, :content-type, :content-length, :last-modified, :created and :resource-type, from the live properties
  • :locks, from DAV:lockdiscovery, as maps of each lock's :token, the :root href, :scope, :depth, :timeout in seconds (or :infinite) and :owner element
The resource map of a `response` of a multistatus, as xml/read-multistatus
returns it, to a request of `url`. It has:

- :href as the server wrote it, and :url, resolved against `url`, when
  it's on the same origin, since a request to it would carry the same
  credentials
- :name, the decoded last segment, when it can name a file, so not e.g.
  ../x
- :props, the values of the properties that came back with a success,
  by name, as xml/value gives them
- :failed, the status of each property that didn't, by name, e.g. 404
  for one that isn't there
- :status and :error, when the response has them
- :collection?, :etag, :content-type, :content-length, :last-modified,
  :created and :resource-type, from the live properties
- :locks, from DAV:lockdiscovery, as maps of each lock's :token, the
  :root href, :scope, :depth, :timeout in seconds (or :infinite) and
  :owner element
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
←Move to previous article
→Move to next article
Ctrl+/Jump to the search field
× close