aboutsummaryrefslogtreecommitdiff
path: root/headers.go
diff options
context:
space:
mode:
authorStefan Majewsky <stefan.majewsky@sap.com>2022-10-28 16:06:40 +0200
committerStefan Majewsky <stefan.majewsky@sap.com>2022-10-28 16:06:40 +0200
commit90dd519a948d06738479c04d331f28dfab99315c (patch)
treed4a9914cb73be3dbe9438b012a08408d79bdb7c9 /headers.go
parentfd6e57b6239655722884a49a86be0f051cc32bde (diff)
parent5cf9b60d2ded95d29827389a1a5901f1068d4337 (diff)
downloadgo-schwift-90dd519a948d06738479c04d331f28dfab99315c.tar.gz
Merge remote-tracking branch 'SuperSandro2000:sha2'
Diffstat (limited to 'headers.go')
-rw-r--r--headers.go64
1 files changed, 31 insertions, 33 deletions
diff --git a/headers.go b/headers.go
index 47a2f73..a4fda78 100644
--- a/headers.go
+++ b/headers.go
@@ -23,55 +23,54 @@ import (
"net/textproto"
)
-//Headers represents a set of request headers or response headers.
+// Headers represents a set of request headers or response headers.
//
-//Users will typically use one of the subtypes (AccountHeaders,
-//ContainerHeaders, ObjectHeaders) instead, which provide type-safe access to
-//well-known headers. The http.Header-like interface on this type can be used
-//read and write arbitary headers. For example, the following calls are
-//equivalent:
+// Users will typically use one of the subtypes (AccountHeaders,
+// ContainerHeaders, ObjectHeaders) instead, which provide type-safe access to
+// well-known headers. The http.Header-like interface on this type can be used
+// read and write arbitrary headers. For example, the following calls are
+// equivalent:
//
// h := make(AccountHeaders)
// h.Headers.Set("X-Account-Meta-Quota-Bytes", "1048576")
// h.BytesUsedQuota().Set(1048576)
-//
type Headers map[string]string
-//Clear sets the value for the specified header to the empty string. When the
-//Headers instance is then sent to the server with Update(), the server will
-//delete the value for that header; cf. Del().
+// Clear sets the value for the specified header to the empty string. When the
+// Headers instance is then sent to the server with Update(), the server will
+// delete the value for that header; cf. Del().
func (h Headers) Clear(key string) {
h[textproto.CanonicalMIMEHeaderKey(key)] = ""
}
-//Del deletes a key from the Headers instance. When the Headers instance is
-//then sent to the server with Update(), a key which has been deleted with
-//Del() will remain unchanged on the server.
+// Del deletes a key from the Headers instance. When the Headers instance is
+// then sent to the server with Update(), a key which has been deleted with
+// Del() will remain unchanged on the server.
//
-//For most writable attributes, 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 most writable attributes, 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 (but not other object attributes), deleting a key will
-//cause that key to be deleted on the server. Del() is identical to Clear() in
-//this case.
+// For object metadata (but not other object attributes), deleting a key will
+// cause that key to be deleted on the server. Del() is identical to Clear() in
+// this case.
func (h Headers) Del(key string) {
delete(h, textproto.CanonicalMIMEHeaderKey(key))
}
-//Get returns the value for the specified header.
+// Get returns the value for the specified header.
func (h Headers) Get(key string) string {
return h[textproto.CanonicalMIMEHeaderKey(key)]
}
-//Set sets a new value for the specified header. Any existing value will be
-//overwritten.
+// Set sets a new value for the specified header. Any existing value will be
+// overwritten.
func (h Headers) Set(key, value string) {
h[textproto.CanonicalMIMEHeaderKey(key)] = value
}
-//ToHTTP converts this Headers instance into the equivalent http.Header
-//instance. The return value is guaranteed to be non-nil.
+// ToHTTP converts this Headers instance into the equivalent http.Header
+// instance. The return value is guaranteed to be non-nil.
func (h Headers) ToHTTP() http.Header {
dest := make(http.Header, len(h))
for k, v := range h {
@@ -80,14 +79,13 @@ func (h Headers) ToHTTP() http.Header {
return dest
}
-//ToOpts wraps this Headers instance into a RequestOpts instance, so that it
-//can be passed to Schwift's various request methods.
+// ToOpts wraps this Headers instance into a RequestOpts instance, so that it
+// can be passed to Schwift's various request methods.
//
// hdr := NewObjectHeaders()
// hdr.ContentType().Set("image/png")
// hdr.Metadata().Set("color", "blue")
// obj.Upload(content, nil, hdr.ToOpts())
-//
func (h Headers) ToOpts() *RequestOptions {
return &RequestOptions{Headers: h}
}
@@ -105,20 +103,20 @@ func headersFromHTTP(src http.Header) Headers {
////////////////////////////////////////////////////////////////////////////////
// specialized accessors on Headers subtypes that are not autogenerated
-//IsDynamicLargeObject returns true if this set of headers belongs to a Dynamic
-//Large Object (DLO).
+// IsDynamicLargeObject returns true if this set of headers belongs to a Dynamic
+// Large Object (DLO).
func (h ObjectHeaders) IsDynamicLargeObject() bool {
return h.Headers.Get("X-Object-Manifest") != ""
}
-//IsStaticLargeObject returns true if this set of headers belongs to a Static
-//Large Object (SLO).
+// IsStaticLargeObject returns true if this set of headers belongs to a Static
+// Large Object (SLO).
func (h ObjectHeaders) IsStaticLargeObject() bool {
return h.Headers.Get("X-Static-Large-Object") == "True"
}
-//IsLargeObject returns true if this set of headers belongs to a large object
-//(either an SLO or a DLO).
+// IsLargeObject returns true if this set of headers belongs to a large object
+// (either an SLO or a DLO).
func (h ObjectHeaders) IsLargeObject() bool {
return h.IsDynamicLargeObject() || h.IsStaticLargeObject()
}