webdav: set 'getlastmodified' live property for directories

WebDAV clients can't sort folders by date because 'getlastmodified' live
property is not set.

Fixes golang/go#15334.

Change-Id: Ie56fcf8ae98173878e0972c0f9401151953334ff
Reviewed-on: https://go-review.googlesource.com/23422
Reviewed-by: Nigel Tao <nigeltao@golang.org>
This commit is contained in:
H. İbrahim Güngör
2016-05-25 16:11:03 +03:00
committed by Nigel Tao
parent dfd9ed699e
commit 30db96677b
2 changed files with 12 additions and 1 deletions

View File

@@ -118,7 +118,14 @@ var liveProps = map[xml.Name]struct {
},
xml.Name{Space: "DAV:", Local: "getlastmodified"}: {
findFn: findLastModified,
dir: false,
// http://webdav.org/specs/rfc4918.html#PROPERTY_getlastmodified
// suggests that getlastmodified should only apply to GETable
// resources, and this package does not support GET on directories.
//
// Nonetheless, some WebDAV clients expect child directories to be
// sortable by getlastmodified date, so this value is true, not false.
// See golang.org/issue/15334.
dir: true,
},
xml.Name{Space: "DAV:", Local: "creationdate"}: {
findFn: nil,

View File

@@ -77,6 +77,7 @@ func TestMemPS(t *testing.T) {
{Space: "DAV:", Local: "resourcetype"},
{Space: "DAV:", Local: "displayname"},
{Space: "DAV:", Local: "supportedlock"},
{Space: "DAV:", Local: "getlastmodified"},
},
}, {
op: "propname",
@@ -105,6 +106,9 @@ func TestMemPS(t *testing.T) {
}, {
XMLName: xml.Name{Space: "DAV:", Local: "displayname"},
InnerXML: []byte("dir"),
}, {
XMLName: xml.Name{Space: "DAV:", Local: "getlastmodified"},
InnerXML: nil, // Calculated during test.
}, {
XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"},
InnerXML: []byte(lockEntry),