aboutsummaryrefslogtreecommitdiff
path: root/metadata.go
diff options
context:
space:
mode:
authorStefan Majewsky <majewsky@gmx.net>2018-02-04 22:42:31 +0100
committerStefan Majewsky <majewsky@gmx.net>2018-02-04 22:42:31 +0100
commit698cd6aaf4e4fd235d5af904376c89f8faf177f7 (patch)
tree2323352b54762966f5794cc47c5fd540a755a4ee /metadata.go
parent137f2df4bc383058d59cc0b283c41ef11a1eaebd (diff)
downloadgo-schwift-698cd6aaf4e4fd235d5af904376c89f8faf177f7.tar.gz
add tests for metadata
Diffstat (limited to 'metadata.go')
-rw-r--r--metadata.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/metadata.go b/metadata.go
index 3e01c02..5f5f63f 100644
--- a/metadata.go
+++ b/metadata.go
@@ -50,7 +50,24 @@ func NewMetadata(args ...string) Metadata {
return m
}
+//Clear sets the value to this key to the empty string, such that a Post() with
+//this Metadata will remove the existing value from this metadata key on the server.
+func (m Metadata) Clear(key string) {
+ m.Set(key, "")
+}
+
//Del works just like http.Header.Del().
+//
+//Del deletes a key from the Metadata instance. When the Metadata instance
+//is then sent to the server with Post(), Del() has different effects depending
+//on context because of Swift's inconsistent API:
+//
+//For account or container metadata, a key which has been deleted with Del() will
+//remain unchanged on the server. To remove the key on the server, use Clear()
+//instead.
+//
+//For object metadata, deleting a key will cause that key to be deleted on the
+//server. Del() is identical to Clear() in this case.
func (m Metadata) Del(key string) {
k := textproto.CanonicalMIMEHeaderKey(key)
delete(m, k)