Commit Graph

44 Commits

Author SHA1 Message Date
shoopea f073d3021d remove all debug 2024-01-20 12:33:07 +01:00
shoopea 45e36d9254 details 2024-01-20 12:11:08 +01:00
shoopea 526c74ad21 fix 2024-01-20 12:06:08 +01:00
shoopea 1dc1a2b378 still more debug 2024-01-20 12:05:02 +01:00
Christoph Polcin 036581a6c8 io.Discard is already handeld by Body.Close() 2023-06-22 13:32:03 +02:00
Christoph Polcin ca40e2802e Feat: Authentication API
The changes simplify the `req` method by moving the
authentication-related code into the API.
This makes it easy to add additional authentication methods.

The API introduces an `Authorizer` that acts as an
authenticator factory. The authentication flow itself
is divided down into `Authorize` and `Verify` steps in order
to encapsulate and control complex authentication challenges.

The default `NewAutoAuth` negotiates the algorithms.
Under the hood, it creates an authenticator shim per request,
which delegates the authentication flow to our authenticators.

The `NewEmptyAuth` and `NewPreemptiveAuth` authorizers
allow you to have more control over algorithms and resources.

The API also allows interception of the redirect mechanism by setting
the `XInhibitRedirect` header.

This closes: #15 #24 #38
2023-06-22 13:32:03 +02:00
Christoph Polcin 2c20e7e763 Revert "feat: handle 404 on propfind (#57)"
This reverts commit 8190232c06.
2022-10-16 00:59:14 +02:00
Christoph Polcin 4adca27344 uses log instead of fmt 2022-10-15 14:44:49 +02:00
Felipe Martin Garcia 8190232c06
feat: handle 404 on propfind (#57)
Client.Stat was not returning a proper Go err for not found files, the
ideal way to check this is using `errors.Is(err, fs.ErrNotExist)` but
the client was returning a generic error.

I've updated the `propfind` to take 404 errors into account, retuning
the above error making easier to evaluate that kind of situations.
2022-10-13 23:11:52 +02:00
Ringo Hoffmann c7b1ff8a5e
Improve Error Handling (#54)
* bubble up request errors [#28]

* inhibit stream close on request

* add `StatusError`

* `PUT`: check if given target is a directory

* Revert "inhibit stream close on request"

Cherry-picked into branch dev-bodyclosing.

This reverts commit 2889239999.

Co-authored-by: Christoph Polcin <coco@miconoco.de>
2022-01-28 17:20:35 +01:00
Christoph Polcin b5bd04e2b5 Escapes destination path on copy and move #42 2022-01-27 16:32:05 +01:00
Ringo Hoffmann 3f8721cd4b fix crash when req is called with no body 2021-11-09 09:32:28 +01:00
Ringo Hoffmann 2f2cda4122 use seeker when available on request 2021-11-08 09:54:01 +01:00
Mark Severson 7ff61aa87b Handle request errors in copymove 2021-06-30 12:06:26 +02:00
Felix Pojtinger 4145fa842c Add ability to define custom interceptors (fixes #35) 2021-04-27 23:12:51 +02:00
Jarek Kowalski 617404b525 fixed panic due to concurrent map writes
Fixes #36
2020-09-28 11:17:19 +02:00
Justus Flerlage 9f625b1b8e Added check for root path 2019-11-14 22:08:20 +02:00
Justus Flerlage e53b818e1b Added check of parentPath in createParentCollection 2019-11-14 22:08:20 +02:00
vitalii ff7f737904 fix(requests.go): allow www-authenticate to be case-insensitive. close #32 2019-10-05 22:13:01 +03:00
vitalii 4d70d7ea28 use 'application/xml' instead of 'text/xml'. related with (1) in #15 2018-12-29 22:04:04 +02:00
yatsen1 8bcb1b383c Fix early defer panic. (#29) 2018-11-08 09:39:42 +01:00
vitalii a68e21e92b requests: nil pointer dereference panic was fixed [#25]
http.Do() method will return non-nil [error] in following cases:
1. Request is nil
2. Response missing Location header
3. Client failed to parse Location header
4. Method "request.GetBody()" returns error
5. Http.Client.Send() returns error
5. Client timeout was exceeded

Signed-off-by: Christoph Polcin <labs@polcin.de>
2018-10-21 11:15:52 +02:00
Christoph Polcin 3cd755d6c4 make check api 2018-07-14 01:55:58 +02:00
Vitalii 83e3d1e31e Creating parent collection method was added (#22)
* method for creating parent collection was added to Client struct

"func (c *Client) createParentCollection(itemPath string) error" was added to request.go file

* using Client's method to create parent collection

in following methods:
Client.Write()
Client.WriteStream()
Client.copymove()

deadlock is impossible in method Client.copymove() because of paragraph #6 section 9.8.5 (https://tools.ietf.org/html/rfc4918#section-9.8.5) and paragraph #6 section 9.9.4 (https://tools.ietf.org/html/rfc4918#section-9.9.4) of RFC 4918 (https://tools.ietf.org/html/rfc4918)

* install dependencies script was added to Travis-CI file

* testing was added to Travis-CI file

* error wrapping was removed from Client.put() method

* using an early return on error in case of 409 in Client.Write() method
2018-07-14 01:48:30 +02:00
Vitalii f43a0a4cf8 quick bugfix for issue #20 (#21)
issue title: "Can't upload file with content"
https://github.com/studio-b12/gowebdav/issues/20
2018-07-08 14:25:00 +02:00
Christoph Polcin c4c24955e1 update README 2018-06-19 08:43:13 +02:00
David b45378c08f Check status on every request to fix #14 2018-06-18 10:02:01 -05:00
misha-plus 9ff8e33634 fix authorization 2018-06-10 11:01:51 +02:00
David 6d8c168f72 Add Authenticator interface and Digest auth support 2018-05-25 22:40:13 +02:00
Christoph Polcin 375f391c8a Escape URL 2018-05-23 13:41:06 +02:00
Shishkin Artem c49c91989e % and # in the URL 2018-05-22 12:34:34 +02:00
Aaron Bieber beeefa572c more docs / cleanup 2018-05-16 10:42:53 +02:00
Christoph Polcin 0c00ff98a3 close body 2014-10-27 16:29:57 +01:00
Christoph Polcin f03693b770 refactor copymove 2014-10-27 16:27:57 +01:00
Christoph Polcin b947e819ed refactor req & reqDo 2014-10-27 16:19:17 +01:00
Christoph Polcin e4fac5eebf implement READ & WRITE 2014-10-27 14:32:16 +01:00
Christoph Polcin 1cd7bd1100 ref CopyRename TODOs 2014-10-24 14:09:50 +02:00
Christoph Polcin 47076d6487 add Rename and Copy 2014-10-24 14:09:50 +02:00
Christoph Polcin f728828956 ReadDir will fail on non collections 2014-10-24 12:39:35 +02:00
Christoph Polcin 544a4735b6 don't export requests 2014-10-23 15:31:34 +02:00
Christoph Polcin c1fc968bc9 implement MkDir aka MKCOL 2014-10-23 15:00:20 +02:00
Christoph Polcin d4b8ebb4b2 implement Remove 2014-10-23 14:10:31 +02:00
Christoph Polcin 542e8e73bc refactor func parseXML 2014-10-23 11:29:26 +02:00
Christoph Polcin 95f1f68142 add initial source 2014-10-23 10:39:55 +02:00