serve webdav: make Content-Type without reading the file and add --etag-hash

Before this change x/net/webdav would open each file to find out its
Content-Type.

Now we override the FileInfo and provide that directly from rclone.

An --etag-hash has also been implemented to override the ETag with the
hash passed in.

Fixes #2273
This commit is contained in:
Nick Craig-Wood
2018-08-26 21:50:41 +01:00
parent 94950258a4
commit b3217d2cac
2 changed files with 126 additions and 10 deletions
+8
View File
@@ -16,6 +16,7 @@ import (
"github.com/ncw/rclone/cmd/serve/httplib"
"github.com/ncw/rclone/fstest"
"github.com/stretchr/testify/assert"
"golang.org/x/net/webdav"
)
const (
@@ -23,6 +24,13 @@ const (
testURL = "http://" + testBindAddress + "/"
)
// check interfaces
var (
_ os.FileInfo = FileInfo{nil}
_ webdav.ETager = FileInfo{nil}
_ webdav.ContentTyper = FileInfo{nil}
)
// TestWebDav runs the webdav server then runs the unit tests for the
// webdav remote against it.
func TestWebDav(t *testing.T) {