Example session:
$ mkdir test-data $ WikiDirTestData=test-data perl server.pl daemon $ cadaver dav:!> open http://localhost:3000/wiki/dav/ dav:/wiki/dav/> ls Listing collection `/wiki/dav/': succeeded. HomePage 5 May 21 21:24
You can follow along using `tail -f test-data/wiki.log` if you have set `$verbose = 1` in the source code.
This is what Cadaver sends when it connects and the response it gets:
OPTIONS /dav/ PROPFIND /dav/ depth: infinity <?xml version="1.0" encoding="utf-8"?> <propfind xmlns="DAV:"><prop> <getcontentlength xmlns="DAV:"/> <getlastmodified xmlns="DAV:"/> <executable xmlns="http://apache.org/dav/props/"/> <resourcetype xmlns="DAV:"/> <checked-in xmlns="DAV:"/> <checked-out xmlns="DAV:"/> </prop></propfind> RESPONSE: 207 <?xml version="1.0" encoding="utf-8"?> <D:multistatus xmlns:D="DAV:"> <D:response xmlns:i0="http://apache.org/dav/props/"> <D:href>/wiki/dav/</D:href> <D:propstat> <D:prop> <D:getcontentlength/> <D:getlastmodified>Thu, 01 Jan 1970 00:00:00 GMT</D:getlastmodified> <D:resourcetype> <D:collection/> </D:resourcetype> </D:prop> <D:status>HTTP/1.1 200 OK</D:status> </D:propstat> <D:propstat> <D:prop> <i0:executable/> <D:checked-in/> <D:checked-out/> </D:prop> <D:status>HTTP/1.1 404 Not Found</D:status> </D:propstat> </D:response> <D:response xmlns:i0="http://apache.org/dav/props/"> <D:href>/wiki/dav/HomePage</D:href> <D:propstat> <D:prop> <D:getcontentlength>5</D:getcontentlength> <D:getlastmodified>Sun, 21 May 2017 19:24:46 GMT</D:getlastmodified> <D:resourcetype/> </D:prop> <D:status>HTTP/1.1 200 OK</D:status> </D:propstat> <D:propstat> <D:prop> <i0:executable/> <D:checked-in/> <D:checked-out/> </D:prop> <D:status>HTTP/1.1 404 Not Found</D:status> </D:propstat> </D:response> </D:multistatus>
Issue the *ls* command:
dav:/wiki/dav/> ls Listing collection `/wiki/dav/': succeeded. HomePage 5 May 21 21:24
And the `PROPFIND` is the same:
PROPFIND /dav/ depth: 1 <?xml version="1.0" encoding="utf-8"?> <propfind xmlns="DAV:"><prop> <getcontentlength xmlns="DAV:"/> <getlastmodified xmlns="DAV:"/> <executable xmlns="http://apache.org/dav/props/"/> <resourcetype xmlns="DAV:"/> <checked-in xmlns="DAV:"/> <checked-out xmlns="DAV:"/> </prop></propfind> RESPONSE: 207 <?xml version="1.0" encoding="utf-8"?> <D:multistatus xmlns:D="DAV:"> <D:response xmlns:i0="http://apache.org/dav/props/"> <D:href>/wiki/dav/</D:href> <D:propstat> <D:prop> <D:getcontentlength/> <D:getlastmodified>Thu, 01 Jan 1970 00:00:00 GMT</D:getlastmodified> <D:resourcetype> <D:collection/> </D:resourcetype> </D:prop> <D:status>HTTP/1.1 200 OK</D:status> </D:propstat> <D:propstat> <D:prop> <i0:executable/> <D:checked-in/> <D:checked-out/> </D:prop> <D:status>HTTP/1.1 404 Not Found</D:status> </D:propstat> </D:response> <D:response xmlns:i0="http://apache.org/dav/props/"> <D:href>/wiki/dav/HomePage</D:href> <D:propstat> <D:prop> <D:getcontentlength>5</D:getcontentlength> <D:getlastmodified>Sun, 21 May 2017 19:24:46 GMT</D:getlastmodified> <D:resourcetype/> </D:prop> <D:status>HTTP/1.1 200 OK</D:status> </D:propstat> <D:propstat> <D:prop> <i0:executable/> <D:checked-in/> <D:checked-out/> </D:prop> <D:status>HTTP/1.1 404 Not Found</D:status> </D:propstat> </D:response> </D:multistatus>
Read the page using *get*:
dav:/wiki/dav/> get HomePage Downloading `/wiki/dav/HomePage' to HomePage: [..] succeeded.
The request is simple:
GET /dav/HomePage
Edit the file you downloaded and save it:
dav:/wiki/dav/> put HomePage Uploading HomePage to `/wiki/dav/HomePage': Progress: [=============================>] 100.0% of 8 bytes succeeded.
And the request:
PUT /dav/HomePage RESPONSE: 204
But... no data is being read?
See OS X Finder and WebDAV.
#Cadaver #WebDAV