瀏覽代碼

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>
H. İbrahim Güngör 9 年之前
父節點
當前提交
30db96677b
共有 2 個文件被更改,包括 12 次插入1 次删除
  1. 8 1
      webdav/prop.go
  2. 4 0
      webdav/prop_test.go

+ 8 - 1
webdav/prop.go

@@ -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,

+ 4 - 0
webdav/prop_test.go

@@ -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),