7

Is there a minimal (possibly annotated) example of a typical request-response cycle, with both headers and body. As I understand it, this consists of an initial OPTIONS and a subsequent PROPFIND exchange - after that, GET and PUT should be straightforward, so I don't need a generic example there.

I've been considering exposing existing RESTful resources (collections and individual items within) via WebDAV. I only need basic functionality to work - listing directories, reading and writing files - which AFAICT means adding PROPFIND support should suffice.

nes1983
  • 15,209
  • 4
  • 44
  • 64
AnC
  • 4,099
  • 8
  • 43
  • 69
  • OPTIONS is purely ... optional. What needs to be implemented depends mainly on the client you want to use. – Julian Reschke Apr 13 '12 at 18:06
  • 1
    Indeed - but anecdotal evidence suggests that most clients are pretty liberal. I'm mainly interested in Windows Explorer, Linux (davfs2) and OS X Finder. – AnC Apr 13 '12 at 20:20

1 Answers1

14

The specification includes examples:

Minimal

Request:

OPTIONS /somecollection/ HTTP/1.1
Host: example.org

Response:

HTTP/1.1 200 OK
Allow: OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, COPY, MOVE
Allow: MKCOL, PROPFIND, PROPPATCH, LOCK, UNLOCK, ORDERPATCH
DAV: 1, 2, ordered-collections

Realistic

Request:

  PROPFIND /somecollection HTTP/1.1
    Depth: 0
    Content-Type: text/xml; charset="utf-8"
    Content-Length: xxx

    <?xml version="1.0" encoding="UTF-8" ?>
    <propfind xmlns="DAV:">
      <prop>
        <supported-live-property-set/>
        <supported-method-set/>
      </prop>
    </propfind>

Response:

HTTP/1.1 207 Multi-Status
Content-Type: text/xml; charset="utf-8"
Content-Length: xxx

<?xml version="1.0" encoding="utf-8" ?>
<multistatus xmlns="DAV:">
  <response>
    <href>http://example.org/somecollection</href>
    <propstat>
      <prop>
        <supported-live-property-set>
          <supported-live-property>
            <prop><ordering-type/></prop>
          </supported-live-property>
          <!-- ... other live properties omitted for brevity ... -->
        </supported-live-property-set>
        <supported-method-set>
          <supported-method name="COPY" />
          <supported-method name="DELETE" />
          <supported-method name="GET" />
          <supported-method name="HEAD" />
          <supported-method name="LOCK" />
          <supported-method name="MKCOL" />
          <supported-method name="MOVE" />
          <supported-method name="OPTIONS" />
          <supported-method name="ORDERPATCH" />
          <supported-method name="POST" />
          <supported-method name="PROPFIND" />
          <supported-method name="PROPPATCH" />
          <supported-method name="PUT" />
          <supported-method name="TRACE" />
          <supported-method name="UNLOCK" />
        </supported-method-set>
      </prop>
      <status>HTTP/1.1 200 OK</status>
    </propstat>
  </response>
</multistatus>
nes1983
  • 15,209
  • 4
  • 44
  • 64
  • Thanks, this explains most of my issues: a) I had used regular(?) rather than live properties, plus I think I'd only looked at RFC4918. b) [cadaver](http://www.webdav.org/cadaver/) reports "Could not access /somecollection (not WebDAV-enabled?): Did not find a collection resource.", which was a big part of my confusion. Ignoring this (`-t`) succeeds in listing the expected resource using that XML sample. I've accepted your response gratefully - in case I run into more issues, I will open a new, more specific question. – AnC Apr 13 '12 at 20:28