- sync-collection answers 403 unless the path is a calendar, and not a
schedule inbox or outbox. A missing sync-level is level 1.
- DAV:sync-token is not returned for DAV:allprop (RFC 6578 section 4).
- schedule-response carries calendar-data only for a 2.x request-status.
- XML responses with a status other than 200 (207 and errors) set
Content-Type before WriteHeader, so it is no longer dropped.
- Docs: sync-tokens are URIs; FreeBusyBackend advertises
calendar-auto-schedule, so the backend owns scheduling.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Calendar gains CTag (CS:getctag), SyncToken (DAV:sync-token) and
Transparent (CALDAV:schedule-calendar-transp). Three optional Backend
interfaces, checked with type assertions:
- SyncBackend answers the sync-collection REPORT (RFC 6578) and adds
DAV:supported-report-set to calendars. ErrInvalidSyncToken gives 403
with DAV:valid-sync-token.
- PrincipalBackend serves calendar-user-address-set, schedule-inbox-URL
and schedule-outbox-URL on the principal, and the inbox and outbox
collections themselves (RFC 6638 section 2).
- FreeBusyBackend answers a VFREEBUSY POST to the outbox with a
schedule-response (RFC 6638 section 10.3), and adds
calendar-auto-schedule to the DAV header.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
RFC 4918 sections 9.8.5 and 9.9.4 say the server should return 403 when
the source and destination are the same. Overwriting the destination
deletes the source, so LocalFileSystem lost the file.
Check this in the shared handler so every backend gets it.
The walk ignored the path of each entry: it created dstPath for every directory
and copied srcPath to dstPath for every file, so copying a non-empty directory
failed with "open: is a directory". With Overwrite the destination had already
been removed, so its files were lost. Copy each entry to its own path under the
destination.
Read the calendar-color property in the http://apple.com/ns/ical/
namespace in FindCalendar and FindCalendars, and report it in PROPFIND
responses when it is set, the same way as calendar-description.
QueryCalendar and MultiGetCalendar returned no objects at all when the
calendar-data of one of them failed to parse. Skip that object instead
and report its error, with its href, in the returned error, like
multistatus errors since 71ae569.
PutCalendarObject and PutAddressObject sent no conditional request
headers, so a client could not perform an optimistic-concurrency write
(overwrite only if the resource still carries an expected ETag). Add an
options parameter to both, reusing the existing server-side
PutCalendarObjectOptions / PutAddressObjectOptions types so the client
and Backend interface mirror each other. A nil opts preserves the prior
unconditional behaviour; a non-nil opts sets If-Match / If-None-Match.
Signed-off-by: Henry Stern <henry@stern.ca>
Assisted-by: Claude Opus 4.8 <noreply@anthropic.com>
Closes: https://github.com/emersion/go-webdav/issues/130
Client.RemoveAll had no way to send conditional headers, so a client
could not delete a resource only if it still has a known ETag. Take a
*RemoveAllOptions, the same type FileSystem.RemoveAll uses on the server
side. A nil value keeps the previous unconditional behavior.
SyncCollection already requests calendar-data via the query's CompRequest, but
only the ETag and last-modified props were decoded, so a caller had to follow
every sync with a multiget even when the server (e.g. Radicale, SOGo) returned
the calendar object inline in the sync-collection response.
Decode the calendar-data prop into CalendarObject.Data when it is present; when
the server omits it, Data is left nil and the caller fetches it with a multiget
as before. Backward compatible.
Signed-off-by: Henry Stern <henry@stern.ca>
Assisted-by: Claude (Anthropic) <noreply@anthropic.com>
The server hard-coded DAV:read + DAV:write in current-user-privilege-set for
every collection (with a TODO). Add a ReadOnly field to Calendar and AddressBook
that the backend sets per request; report DAV:write only when it is false, so
clients (e.g. DAVx5, Apple) correctly mark read-only collections. Default
(false) keeps the previous read-write behavior.
This change adds FindCalendar function to the caldav client. It can be
used to get calendar information without loading all the events, once the
path of the calendar is known.
The previous code failed to properly handle PROPFIND with an empty request body
(RFC 4918 section 9.1) for XML content type requests.
Refactor the logic to always consider PROPFIND requests with empty request
bodies as "allprop" requests, regardless of content type.
There is no need to worry about the request's content type if the request body
is empty anyway, so only parse if we know it is not.
This change set implements the "context path" discovery for the
CalDav/CardDav endpoints.
This basically implements the bootstrapping process as defined in
RFC6764 section 6, point 2 and 3.
What's missing in this implementation is the fallback that is described
in point 3, subpoint 3, which says that if the context path discovered
in the TXT RR is not reachable the .well-known URI should be used
instead.
I propose to implement this in a future iteration.
NewPropFindResponse uses callbacks to lazily build the response.
However, some props are static: they don't require any processing
to generate. Add a small helper to reduce boilerplate a bit.