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
Simon Ser
489be203a1
webdav: add Client.MoveAll
2020-01-22 10:15:44 +01:00
Simon Ser
d30d4d2932
internal: add helpers for the Overwrite header
2020-01-22 10:09:51 +01:00
Simon Ser
c0a91b0085
internal: move Depth to internal.go
2020-01-22 10:06:00 +01:00
Simon Ser
90fe8dedf7
internal: add PROPPATCH support to server
2020-01-21 23:18:27 +01:00
Simon Ser
e9e1f102de
webdav: add MKCOL support to server
2020-01-21 22:05:59 +01:00
Simon Ser
41b68829e8
webdav: add DELETE support to server
2020-01-21 21:46:01 +01:00
Simon Ser
7d6de88179
webdav: add support for PUT to server
2020-01-21 21:19:44 +01:00
Simon Ser
63cdea07be
internal: allow Response.DecodeProp to decode multiple values
2020-01-21 18:41:25 +01:00
Simon Ser
3e41eefd12
internal: properly encode path in Client.NewRequest
2020-01-20 13:40:26 +01:00
Simon Ser
3a61646ab4
carddav: add current-user-principal to server
2020-01-20 10:56:25 +01:00
Simon Ser
d8ce7d353d
internal: check for response error in Multistatus.Get
2020-01-19 15:41:08 +01:00
Simon Ser
6e0ea58de1
carddav: populate AddressBook.{Name,MaxResourceSize} in client
2020-01-19 15:29:51 +01:00
Simon Ser
edfc2804b5
carddav: add displayname and addressbook-description to server
2020-01-19 14:53:58 +01:00
Simon Ser
b311299ac0
internal: add Prop.Get, Prop.Decode
2020-01-19 12:01:55 +01:00
Simon Ser
f3f1c8b58a
internal: introduce DecodeXMLRequest, ServeXML and ServeMultistatus
2020-01-19 11:12:45 +01:00