# Support \`PutStream\` for webdav servers with partial update support

**URL:** <https://forum.rclone.org/t/support-putstream-for-webdav-servers-with-partial-update-support/27247>\
**Category:** Feature\
**Created:** [November 1, 2021, 5:19pm UTC](https://forum.rclone.org/t/support-putstream-for-webdav-servers-with-partial-update-support/27247 "2021-11-01T17:19:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vigilans](https://forum.rclone.org/user_avatar/forum.rclone.org/vigilans/32/10606_2.png) [@Vigilans](https://forum.rclone.org/u/Vigilans)\
**Post date:** [November 1, 2021, 5:19pm UTC](https://forum.rclone.org/t/support-putstream-for-webdav-servers-with-partial-update-support/27247/1 "2021-11-01T17:19:03Z")

</div>

#### What problem are you are trying to solve?

Currently, WebDAV's `Putstream` feature is disabled for all vendors except owncloud:

> <https://github.com/rclone/rclone/blob/169990e270b2977c39bd6ecd8a2921cf30a6d2b7/backend/webdav/webdav.go#L588-L591>

Which will result in 1. A warning when using `rclone mount` with webdav server:

> <https://github.com/rclone/rclone/blob/169990e270b2977c39bd6ecd8a2921cf30a6d2b7/vfs/vfs.go#L229-L232>

and 2. `RCat` operation in `rclone mount` will create a temporary local fs, copy the object to tmpLocalFs, finally sending the whole object to webdav server:

> <https://github.com/rclone/rclone/blob/169990e270b2977c39bd6ecd8a2921cf30a6d2b7/fs/operations/operations.go#L1323-L1338>

Therefore, when copying a file to a mounted webdav server, the progress bar will finish in a second, but the file is actually being uploaded in the background.

This is not user friendly as completed file uploading cannot be indicated by a finished progress bar.

#### How do you think rclone should be changed to solve that?

If a webdav remote supports partial update, then we could provide `PutStream` feature based on its partial update specification, so the problem is resolved.

Although how partial update should work is not specified in webdav specification, there are several non-standard ways implemented by some widely used webdav providers:

- [SABREDAV's partial update by HTTP PATCH](https://github.com/miquels/webdav-handler-rs/blob/master/doc/SABREDAV-partialupdate.md) ([owncloud uses this](https://owncloud.com/news/owncloud-and-sabredav/))
- [Apache's PUT with Content-Range](https://github.com/miquels/webdav-handler-rs/blob/master/doc/Apache-PUT-with-Content-Range.md)

New open source webdav servers generally recognize these two implementations as de facto standard, like this [rust implementation for webdav server](https://github.com/miquels/webdav-handler-rs). So, by supporting these two partial update methods, varieties of webdav remotes will benefit from it.

These two methods all provide some ways to inform clients of their existence.

[For SABREDAV](https://github.com/miquels/webdav-handler-rs/blob/master/doc/SABREDAV-partialupdate.md#options):

> If you want to be compliant with SabreDAV's implementation of PATCH, you must also return 'sabredav-partialupdate' in the 'DAV:' header:
> 
> ```auto
> HTTP/1.1 204 No Content
> DAV: 1, 2, 3, sabredav-partialupdate, extended-mkcol
> 
> ```
> 
> This is only required if you are adding this feature to a DAV server. For non-webdav implementations such as REST services this is optional.

[For Apache](https://github.com/miquels/webdav-handler-rs/blob/master/doc/Apache-PUT-with-Content-Range.md#reckognizing-put-with-content-range-support-client):

> There is no official way to know if PUT-with-content-range is supported by a webserver. For a client it's probably best to do an OPTIONS request, and then check two things:
> 
> - the `Server` header must contain the word `Apache`
> - the `DAV` header must contain `<http://apache.org/dav/propset/fs/1>`.
> 
> In that case, your are sure to talk to an Apache webserver with mod\_dav enabled.

Therefore, support of partial update feature could be auto-detected and hence no need to change the option (Or maybe some vendors could be added to allow users to manually indicate partial update is supported?).

If this is a feature worth to support, I am willing to implement it myself, and hence seek for suggestions and guidance about the desired design, where to put the auto detection code, etc.

#### Related Posts

> [@Rclone mount, show progress bar on copy / move?](https://forum.rclone.org/t/rclone-mount-show-progress-bar-on-copy-move/10023):
>
> I'm using rclone on Windows 10, and I was wondering if there's a way to make windows explorer (or any other file manager on windows) display a precise progress bar when copying / moving files into a mounted drive. The way it currently works for me is that whatever file I put into the mounted drive, it just appears there almost instantly, and the actual upload takes place in the background thus I have no idea when it finishes or how fast it's going. Thanks! Using OneDrive Windows 10 18362.113…

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [November 1, 2021, 8:37pm UTC](https://forum.rclone.org/t/support-putstream-for-webdav-servers-with-partial-update-support/27247/2 "2021-11-01T20:37:21Z")

</div>

> [@Vigilans](#):
>
> Currently, WebDAV's `Putstream` feature is disabled for all vendors except owncloud:

That is probably unnecessarily restrictive...

All that is required for PutStream is that the server supports chunked transfer encoding without a `Content-Length:` header.

This shouldn't be too hard and maybe the servers you want to use really do support it.

Before implementing the partial update (which looks interesting) it might be worth just setting canStream unconditionally and see if your backend works?

I'd also like to implement a quirks system so you can override the quirks rclone chooses for you. This would be useful in a number of backends.

---

<div class="post-metadata">

**Author:** ![Vigilans](https://forum.rclone.org/user_avatar/forum.rclone.org/vigilans/32/10606_2.png) [@Vigilans](https://forum.rclone.org/u/Vigilans)\
**Post date:** [November 3, 2021, 5:06pm UTC](https://forum.rclone.org/t/support-putstream-for-webdav-servers-with-partial-update-support/27247/3 "2021-11-03T17:06:02Z")

</div>

I specified the vendor of my webdav remote to be "owncloud", and did a simple file upload (about 170MB):

1. Upload succeeded with progress bar working as expected;
2. The file is still valid after downloading from remote.

But the rclone mount log shows some errors:

```auto
ERROR : Script.pvf: WriteFileHandle.Write: can't seek in file without --vfs-cache-mode >= writes
ERROR : Script.pvf: WriteFileHandle.Write: can't seek in file without --vfs-cache-mode >= writes
ERROR : Script.pvf: WriteFileHandle.Write: can't seek in file without --vfs-cache-mode >= writes
ERROR : Script.pvf: WriteFileHandle: Truncate: Can't change size without --vfs-cache-mode >= writes

ERROR : Script.pvf: WriteFileHandle.New Rcat failed: corrupted on transfer
ERROR : Script.pvf: WriteFileHandle.Flush error: corrupted on transfer
ERROR : IO error: corrupted on transfer

```

Relevant debug output:

```auto
(Upload begins)

DEBUG : /Script.pvf: Truncate: size=181355213, fh=0x0
ERROR : Script.pvf: WriteFileHandle: Truncate: Can't change size without --vfs-cache-mode >= writes
DEBUG : /Script.pvf: >Truncate: errc=-1

... (After upload finishes) 

DEBUG : Script.pvf: Modification times differ by 17.4935035s: 2021-11-04 00:53:02.5064965 +0800 CST m=+6767.635558101, 2021-11-03 16:53:20 +0000 GMT
ERROR : Script.pvf: corrupted on transfer
ERROR : Script.pvf: WriteFileHandle.New Rcat failed: corrupted on transfer
ERROR : Script.pvf: WriteFileHandle.Flush error: corrupted on transfer
ERROR : IO error: corrupted on transfer

```

Below is the trace I've done until now:

Focus on the errors after upload finished, the error occured during `RCat`'s compare function:

> <https://github.com/rclone/rclone/blob/169990e270b2977c39bd6ecd8a2921cf30a6d2b7/fs/operations/operations.go#L1294-L1307>

Notice the log message `Modification times differ...`, there is no more log message between it and the final `corrupted on transfer` message.

Looking through the source code, only one place will not log any message before return:

> <https://github.com/rclone/rclone/blob/169990e270b2977c39bd6ecd8a2921cf30a6d2b7/fs/operations/operations.go#L217-L229>

So that means `CheckHashs(ctx, src, dst)` returned (true, hash.None, \_), meaning that the hash couldn't be checked. Anything I'm missing? (or derived from incompatibility with "owncloud" vendor?)

---

<div class="post-metadata">

**Author:** ![Vigilans](https://forum.rclone.org/user_avatar/forum.rclone.org/vigilans/32/10606_2.png) [@Vigilans](https://forum.rclone.org/u/Vigilans)\
**Post date:** [November 3, 2021, 5:29pm UTC](https://forum.rclone.org/t/support-putstream-for-webdav-servers-with-partial-update-support/27247/4 "2021-11-03T17:29:09Z")

</div>

> All that is required for PutStream is that the server supports chunked transfer encoding without a `Content-Length:` header.

About the server support, I learned that rclone will pass object of size -1 when calling `PutStream`:

> <https://github.com/rclone/rclone/blob/169990e270b2977c39bd6ecd8a2921cf30a6d2b7/fs/operations/operations.go#L1346-L1347>

and golang's http module will [convert `Content-Length` of `-1` to `Transfer-Encoding: trunked` automatically](https://github.com/golang/go/blob/e0e6e4d23fe840c2c9b4caed30930cad6788b797/src/net/http/transfer.go#L94-L96).

My webdav server uses rust's `hyper` package as http server backend, and [it correctly processed requests without `Content-Length`](https://github.com/hyperium/hyper/blob/0a4b56acb82ef41a3336f482b240c67c784c434f/src/proto/h1/decode.rs#L25-L48).

Therefore, the webdav handler could normally [read and process body from `PUT` request as a stream](https://github.com/miquels/webdav-handler-rs/blob/b8927daec3987604187a6e1881a9e6883ac881f2/src/handle_put.rs#L214-L234).

So that may mean `PutStream` could be easily supported by those webdav servers if based on some mature http implementation like `hyper` (thus no need to introduce partial update for now), the "owncloud" constraint seems unnecessarily restrictive.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [November 4, 2021, 5:51pm UTC](https://forum.rclone.org/t/support-putstream-for-webdav-servers-with-partial-update-support/27247/5 "2021-11-04T17:51:13Z")

</div>

Owncloud sets too many quirks for your provider

```auto
        case "owncloud":
                f.canStream = true
                f.precision = time.Second
                f.useOCMtime = true
                f.hasMD5 = true
                f.hasSHA1 = true

```

You want to set only `f.canStream = true` for this experiment.

What we should really do is make the quirks configurable from the command line.

I think if you try that (you'll have to modify the source) then it should work.

---

<div class="post-metadata">

**Author:** ![aguaviva](https://forum.rclone.org/user_avatar/forum.rclone.org/aguaviva/32/10982_2.png) [@aguaviva](https://forum.rclone.org/u/aguaviva)\
**Post date:** [December 22, 2021, 11:53pm UTC](https://forum.rclone.org/t/support-putstream-for-webdav-servers-with-partial-update-support/27247/6 "2021-12-22T23:53:37Z")

</div>

I am so looking forward to this fix! I'll be happy to test it and report the results.

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [February 21, 2022, 7:54pm UTC](https://forum.rclone.org/t/support-putstream-for-webdav-servers-with-partial-update-support/27247/7 "2022-02-21T19:54:02Z")

</div>

Closed on February 21, 2022, 7:54pm UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
