266c39c655
Add CurrentUserPrivilegeSet to find carddav
2024-09-26 20:53:10 +01:00
Thomas Müller
948f33c2fc
internal: use application/xml instead of text/xml which is deprecated
2024-04-11 17:16:25 +02:00
Thomas Müller
3ed9a4f052
carddav, caldav: add missing headers on PUT
...
ETag and Last-Modified should be set to the new calendar object or
address object properties.
2024-03-28 11:22:46 +01:00
Conrad Hoffmann
25f1014ef2
internal: no status element in propstat responses
...
Responses that contain propstat elements do not contain their own
top-level status element, only the status elements inside the propstat
element.
See https://datatracker.ietf.org/doc/html/rfc4918#section-14.24 or any
of the examples for PROPFIND/PROPPATCH, starting e.g. here:
https://datatracker.ietf.org/doc/html/rfc4918#section-9.1.3
2024-02-08 23:12:59 +01:00
Simon Ser
f1d56f2437
internal: add IsRequestEmpty
2024-02-07 17:23:17 +01:00
Simon Ser
b043bbd965
internal/server: handle PROPFIND without body
...
See RFC 4918 section 9.1.
2024-01-08 14:58:24 +01:00
Simon Ser
7e076258d6
caldav: add DiscoverContextURL
2023-12-27 23:16:49 +01:00
Simon Ser
379a418130
Add context for clients
2023-12-19 21:29:37 +01:00
Sebastien Binet
7d337ac048
internal: fix always-true interface comparison
...
This CL corrects the following bug uncovered by staticcheck:
```
internal/elements.go:148:6: this comparison is always true (SA4023)
internal/elements.go:146:18: the lhs of the comparison gets its value from here and has a concrete type
```
Signed-off-by: Sebastien Binet <binet@cern.ch>
2023-12-15 15:07:59 +01:00
Simon Ser
d7891ce50c
internal: fix XML element struct naming
...
We were sometimes using TitleCase, sometimes Lowercase. Let's align
on the idiomatic Go naming and pick TitleCase everywhere.
2022-05-31 23:04:42 +02:00
Simon Ser
55a9274ba6
internal: use Namespace instead of "DAV:"
2022-05-31 17:10:30 +02:00
Simon Ser
1c71a7a1c4
internal: add more context to Response.DecodeProp errors
2022-05-31 17:04:44 +02:00
Simon Ser
d0fc22a428
internal: use errors.As in IsNotFound
...
Allows it to work properly with wrapped errors.
2022-05-31 16:58:45 +02:00
Simon Ser
9bc7a8f15b
internal: drop Multistatus.Get
...
This is now unused.
2022-05-31 16:11:08 +02:00
Conrad Hoffmann
03633121d9
client: support redirects in PropfindFlat()
...
One common method for CalDAV or CardDAV clients to find the current user
principal URL is to request the `/.well-known` URL (see [RFC 6764,
section 6][1]), expecting a redirect. Such URL is for example a valid
result of the discovery phase described in that RFC. The expectation is
that a client, given such URL, is able to find the principal URL by
following a redirect when sending a PROPFIND request.
This change makes `PropfindFlat()` (and, by extension,
`FindCurrentUserPrincipal()`) handle such a redirect and correctly
return the requested properties, even if their HREF is different from
the original request path.
[1]: https://datatracker.ietf.org/doc/html/rfc6764#section-6
2022-05-31 16:05:54 +02:00
Simon Ser
d8a8af0448
internal: don't send an empty error element
...
According to RFC 4918 section 14.5, the error element can't be empty.
2022-05-02 20:41:33 +02:00
Simon Ser
3f8b212b0d
internal: add Response.Err
...
Builds a detailed HTTPError + Error if the Response is a failure.
It contains more context than just the HTTPError.
2022-05-02 15:43:43 +02:00
Simon Ser
46ebe58ac2
internal: introduce NewErrorResponse
...
Same as NewOKResponse but for errors.
2022-05-02 15:43:43 +02:00
Simon Ser
4e8c5effe3
Replace DAVError with HTTPError + Error
...
That way we can avoid having different ways of representing the
same error value.
2022-05-02 15:43:43 +02:00
Simon Ser
8738a105fc
internal: add HTTPError.Unwrap
...
This allows callers to access the underlying error via errors.Unwrap.
2022-05-02 15:43:43 +02:00
Conrad Hoffmann
85d2b222bb
Add error type representing DAV/XML errors
...
Backends will need some way to signal that a precondition error occurred
(and specifying which one) without causing the server to return a 500.
This commit adds an exported function to create a specific error for
this. The existing error handling routine is slightly adapted to handle
this error in such a way that it returns the desired result.
Usage would be something like:
```
return "", carddav.NewPreconditionError(carddav.PreconditionNoUIDConflict)
```
which triggers the following HTTP response:
```
HTTP/1.1 409 Conflict.
Content-Type: text/xml; charset=utf-8.
Date: Thu, 10 Mar 2022 10:28:56 GMT.
Content-Length: 141.
Connection: close.
<?xml version="1.0" encoding="UTF-8"?>
<error xmlns="DAV:"><no-uid-conflict
xmlns="urn:ietf:params:xml:ns:carddav"></no-uid-conflict></error>
```
This response gets correctly recognized by e.g. Evolution (though it's
handling is not great).
The added error type is generic enough to be used for other stuff also.
As it is not exported (internal package), new functions for creating
such errors would have to be added.
2022-03-10 16:48:11 +01:00
Sebastien Binet
8efde26ef9
internal: use http.TimeFormat to marshal Time values
2021-03-16 18:42:55 +01:00
Apehaenger
ed52608852
Make Response.Path return the path on error
2021-01-12 12:57:28 +01:00
proletarius101
9cd3bb51b9
fix: deprecrated conversion from int64 to string
2020-09-09 16:00:38 +02:00
AlmogBaku
9e23289610
sync-collection for client
2020-05-25 18:28:24 +02:00
Simon Ser
25df841e2b
internal: move HTTPError to common file
...
This is used by both clients and servers now.
2020-05-13 18:24:29 +02:00
Simon Ser
4c0dc5d900
internal: parse WebDAV toplevel <error> elements
2020-05-13 15:02:52 +02:00
Simon Ser
f4e3fe8c0a
internal: add Multistatus.Get test with HTTP error
...
References: https://github.com/emersion/go-webdav/issues/39
2020-04-05 14:37:17 +02:00
AlmogBaku
1b725cb0b9
fixes #33 , remove missingPropError error
2020-04-02 16:48:13 +02:00
Simon Ser
ddf2a85958
Introduce HTTPClient, remove Client.SetBasicAuth
2020-02-19 16:02:49 +01:00
Simon Ser
a81a7014c6
internal: remove outdated TODO
2020-02-12 20:06:06 +01:00
Simon Ser
7d0d522fa7
internal: prevent empty endpoint path from resulting in "." sub-paths
2020-02-12 20:04:31 +01:00
Simon Ser
30eac28d2b
internal: read response body on error
2020-02-12 19:46:05 +01:00
Simon Ser
a892cc58df
internal: only handle relative paths in Client.ResolveHref
...
Don't prepend the endpoint path in front of absolute paths.
2020-02-12 17:13:12 +01:00
Simon Ser
0b2d0a706c
internal: accomodate for trailign slashes in Multistatus.Get
2020-02-12 17:12:21 +01:00
Simon Ser
7f285fdf83
internal: fix Client.PropfindFlat when endpoint has a non-empty path
2020-02-12 16:40:30 +01:00
Simon Ser
9afa59dc22
internal: fix trailing slash getting removed in Client.ResolveHref
2020-02-12 16:40:03 +01:00
Simon Ser
57df6bf316
caldav: add filter XML definition
2020-02-05 17:07:35 +01:00
Simon Ser
f9d728aaeb
carddav: add Client.HasSupport
2020-02-05 16:08:15 +01:00
Simon Ser
3ea3818dd8
internal: fix Status text marshaling
2020-02-03 21:54:55 +01:00
Simon Ser
69d8cf54ff
internal: fix ETag.String returning unquoted string
2020-02-03 21:52:15 +01:00
Simon Ser
25678476db
internal: add ETag
2020-02-03 21:48:31 +01:00
Simon Ser
ca51e9427a
caldav: add Client.QueryCalendar
2020-02-03 17:26:55 +01:00
Simon Ser
dd1527b97e
carddav: allow created address book objects to have a different path
...
Closes: https://github.com/emersion/go-webdav/issues/32
2020-01-30 15:20:10 +01:00
Simon Ser
8937358ac1
Allow servers to return DAV capabilities in OPTIONS
2020-01-29 18:03:47 +01:00
Simon Ser
6de76c94b8
internal: check for HTTP errors in Client.Do
...
Closes: https://github.com/emersion/go-webdav/issues/19
2020-01-22 13:22:45 +01:00
Simon Ser
6d229f4e8a
webdav: add COPY support to server
2020-01-22 13:00:42 +01:00
Simon Ser
f04c1c9421
webdav: add support for ETag to client & server
2020-01-22 12:03:58 +01:00
Simon Ser
3268102d5a
webdav: add MOVE support to server
2020-01-22 11:43:36 +01:00
Simon Ser
6eeeccb96e
all: encode hrefs, replace hrefs with path in public API
...
Closes: https://github.com/emersion/go-webdav/issues/14
Closes: https://github.com/emersion/go-webdav/issues/16
2020-01-22 11:07:30 +01:00