Let's compare WebDAV with Braid for something simple like looking up the current version of the resource.
In WebDAV, you have to:
- Send a PROPFIND request to the URL of the resource you want to check. In the request body, specify the DAV:version-controlled-binding property you want to retrieve, using a custom XML syntax. Here's an example:
PROPFIND /path/to/resource HTTP/1.1
Host: example.com
Depth: 0
Content-Type: application/xml
<?xml version="1.0" encoding="utf-8"?>
<propfind xmlns="DAV:">
<prop>
<version-controlled-binding />
</prop>
</propfind>
- The server responds with a 207 Multi-Status response, with XML to parse: HTTP/1.1 207 Multi-Status
Content-Type: application/xml
<?xml version="1.0" encoding="utf-8"?>
<multistatus xmlns="DAV:">
<response>
<href>/path/to/resource</href>
<propstat>
<prop>
<version-controlled-binding>
<href>/path/to/version/history</href>
</version-controlled-binding>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
This does not yet give you the version -- it tells you a separate URL that contains the version history. So now you have to query that for the version:- Send a REPORT request to that url, and in the request body, specify the DAV:version-tree report you want to retrieve:
REPORT /path/to/version/history HTTP/1.1
Host: example.com
Content-Type: application/xml
<?xml version="1.0" encoding="utf-8"?>
<version-tree xmlns="DAV:">
<prop>
<version-name />
<creator-displayname />
<creation-date />
<comment />
</prop>
</version-tree>
- The server responds with a 207 Multi-Status, with more custom XML for you to parse: HTTP/1.1 207 Multi-Status
Content-Type: application/xml
<?xml version="1.0" encoding="utf-8"?>
<multistatus xmlns="DAV:">
<response>
<href>/path/to/version/1</href>
<propstat>
<prop>
<version-name>1.0</version-name>
<creator-displayname>John Doe</creator-displayname>
<creation-date>2023-05-26T10:00:00Z</creation-date>
<comment>Initial version</comment>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
<response>
<href>/path/to/version/2</href>
<propstat>
<prop>
<version-name>2.0</version-name>
<creator-displayname>Jane Smith</creator-displayname>
<creation-date>2023-05-27T14:30:00Z</creation-date>
<comment>Updated version</comment>
</prop>
<status>HTTP/1.1 200 OK</status>
</propstat>
</response>
</multistatus>
You can find the versions in there, and if you then parse and filter to the most recent version, you can see that the current version is 2.0.That was a LOT of work!
Now let's see it in Braid.
To get the current version, just do a normal GET or a HEAD, and look at the Version: header in the response:
Request:
GET /path/to/resource HTTP/1.1
Response: HTTP 200 Ok
Version: "2.0"
<body of resource>
That's it! It's that simple!Braid is this simple because it is baked into HTTP. It turns out that HTTP itself is already very close to a State Synchronization protocol -- it just needs a few headers, and the ability to stream updated responses when a resource changes. I encourage you to check out the spec, and see how easy it is to do things that were complicated or impossible in WebDAV:
https://datatracker.ietf.org/doc/html/draft-toomim-httpbis-b...