mirror of
https://github.com/golang/net.git
synced 2026-03-31 02:17:08 +09:00
webdav: Advertise exclusive write locks in supportedlock property.
Change-Id: I843c13b5a2f8e58c555ec3be09ca1d2d855126c7 Reviewed-on: https://go-review.googlesource.com/10631 Reviewed-by: Nigel Tao <nigeltao@golang.org>
This commit is contained in:
committed by
Nigel Tao
parent
8d6170202b
commit
84afb0af00
@@ -141,9 +141,13 @@ var liveProps = map[xml.Name]struct {
|
||||
dir: false,
|
||||
},
|
||||
|
||||
// TODO(nigeltao) Lock properties will be defined later.
|
||||
// TODO: The lockdiscovery property requires LockSystem to list the
|
||||
// active locks on a resource.
|
||||
xml.Name{Space: "DAV:", Local: "lockdiscovery"}: {},
|
||||
xml.Name{Space: "DAV:", Local: "supportedlock"}: {},
|
||||
xml.Name{Space: "DAV:", Local: "supportedlock"}: {
|
||||
findFn: findSupportedLock,
|
||||
dir: true,
|
||||
},
|
||||
}
|
||||
|
||||
// TODO(nigeltao) merge props and allprop?
|
||||
@@ -370,3 +374,11 @@ func findETag(fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string
|
||||
// with nanosecond granularity.
|
||||
return fmt.Sprintf(`"%x%x"`, fi.ModTime().UnixNano(), fi.Size()), nil
|
||||
}
|
||||
|
||||
func findSupportedLock(fs FileSystem, ls LockSystem, name string, fi os.FileInfo) (string, error) {
|
||||
return `` +
|
||||
`<lockentry xmlns="DAV:">` +
|
||||
`<lockscope><exclusive/></lockscope>` +
|
||||
`<locktype><write/></locktype>` +
|
||||
`</lockentry>`, nil
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ func TestMemPS(t *testing.T) {
|
||||
xml.Name{Space: "DAV:", Local: "getcontentlength"},
|
||||
xml.Name{Space: "DAV:", Local: "getlastmodified"},
|
||||
xml.Name{Space: "DAV:", Local: "getcontenttype"},
|
||||
xml.Name{Space: "DAV:", Local: "supportedlock"},
|
||||
},
|
||||
}, {
|
||||
op: "propname",
|
||||
@@ -81,6 +82,7 @@ func TestMemPS(t *testing.T) {
|
||||
xml.Name{Space: "DAV:", Local: "getlastmodified"},
|
||||
xml.Name{Space: "DAV:", Local: "getcontenttype"},
|
||||
xml.Name{Space: "DAV:", Local: "getetag"},
|
||||
xml.Name{Space: "DAV:", Local: "supportedlock"},
|
||||
},
|
||||
}},
|
||||
}, {
|
||||
@@ -106,6 +108,14 @@ func TestMemPS(t *testing.T) {
|
||||
}, {
|
||||
XMLName: xml.Name{Space: "DAV:", Local: "getcontenttype"},
|
||||
InnerXML: []byte("text/plain; charset=utf-8"),
|
||||
}, {
|
||||
XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"},
|
||||
InnerXML: []byte(`` +
|
||||
`<lockentry xmlns="DAV:">` +
|
||||
`<lockscope><exclusive/></lockscope>` +
|
||||
`<locktype><write/></locktype>` +
|
||||
`</lockentry>`,
|
||||
),
|
||||
}},
|
||||
}},
|
||||
}, {
|
||||
@@ -131,6 +141,14 @@ func TestMemPS(t *testing.T) {
|
||||
}, {
|
||||
XMLName: xml.Name{Space: "DAV:", Local: "getetag"},
|
||||
InnerXML: nil, // Calculated during test.
|
||||
}, {
|
||||
XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"},
|
||||
InnerXML: []byte(`` +
|
||||
`<lockentry xmlns="DAV:">` +
|
||||
`<lockscope><exclusive/></lockscope>` +
|
||||
`<locktype><write/></locktype>` +
|
||||
`</lockentry>`,
|
||||
),
|
||||
}},
|
||||
}},
|
||||
}, {
|
||||
@@ -160,6 +178,14 @@ func TestMemPS(t *testing.T) {
|
||||
}, {
|
||||
XMLName: xml.Name{Space: "DAV:", Local: "getetag"},
|
||||
InnerXML: nil, // Calculated during test.
|
||||
}, {
|
||||
XMLName: xml.Name{Space: "DAV:", Local: "supportedlock"},
|
||||
InnerXML: []byte(`` +
|
||||
`<lockentry xmlns="DAV:">` +
|
||||
`<lockscope><exclusive/></lockscope>` +
|
||||
`<locktype><write/></locktype>` +
|
||||
`</lockentry>`,
|
||||
),
|
||||
}}}, {
|
||||
Status: http.StatusNotFound,
|
||||
Props: []Property{{
|
||||
@@ -449,6 +475,7 @@ func TestMemPS(t *testing.T) {
|
||||
xml.Name{Space: "DAV:", Local: "getlastmodified"},
|
||||
xml.Name{Space: "DAV:", Local: "getcontenttype"},
|
||||
xml.Name{Space: "DAV:", Local: "getetag"},
|
||||
xml.Name{Space: "DAV:", Local: "supportedlock"},
|
||||
xml.Name{Space: "foo", Local: "bar"},
|
||||
},
|
||||
}},
|
||||
|
||||
Reference in New Issue
Block a user