diff options
| author | Sandro Jäckel <sandro.jaeckel@sap.com> | 2022-10-26 11:31:22 +0200 |
|---|---|---|
| committer | Sandro Jäckel <sandro.jaeckel@sap.com> | 2022-10-26 14:05:42 +0200 |
| commit | 04ce17415f25dbf10eba954212c8428ae630df88 (patch) | |
| tree | 1aca7ceab052f17a44bb903fb5a8bd45202bd54c /headers.go | |
| parent | fd6e57b6239655722884a49a86be0f051cc32bde (diff) | |
| download | go-schwift-04ce17415f25dbf10eba954212c8428ae630df88.tar.gz | |
Format with go 1.19
Diffstat (limited to 'headers.go')
| -rw-r--r-- | headers.go | 64 |
1 files changed, 31 insertions, 33 deletions
@@ -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 arbitary 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() } |
