aboutsummaryrefslogtreecommitdiff
path: root/request.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 /request.go
parentfd6e57b6239655722884a49a86be0f051cc32bde (diff)
parent5cf9b60d2ded95d29827389a1a5901f1068d4337 (diff)
downloadgo-schwift-90dd519a948d06738479c04d331f28dfab99315c.tar.gz
Merge remote-tracking branch 'SuperSandro2000:sha2'
Diffstat (limited to 'request.go')
-rw-r--r--request.go22
1 files changed, 10 insertions, 12 deletions
diff --git a/request.go b/request.go
index 266bee2..2e78f00 100644
--- a/request.go
+++ b/request.go
@@ -21,24 +21,22 @@ package schwift
import (
"context"
"io"
- "io/ioutil"
"net/http"
"net/url"
"strings"
)
-//RequestOptions is used to pass additional headers and values to a request.
+// RequestOptions is used to pass additional headers and values to a request.
//
-//When preparing a RequestOptions instance with additional headers, the
-//preferred way is to create an AccountHeaders, ContainerHeaders and
-//ObjectHeaders instance and use the type-safe API on these types. Then use the
-//ToOpts() method on that instance. For example:
+// When preparing a RequestOptions instance with additional headers, the
+// preferred way is to create an AccountHeaders, ContainerHeaders and
+// ObjectHeaders instance and use the type-safe API on these types. Then use the
+// ToOpts() method on that instance. For example:
//
// hdr := NewObjectHeaders()
// hdr.ContentType().Set("image/png")
// hdr.Metadata().Set("color", "blue")
// opts := hdr.ToOpts() //type *schwift.RequestOptions
-//
type RequestOptions struct {
Headers Headers
Values url.Values
@@ -65,7 +63,7 @@ func cloneRequestOptions(orig *RequestOptions, additional Headers) *RequestOptio
return &result
}
-//Request contains the parameters that can be set in a request to the Swift API.
+// Request contains the parameters that can be set in a request to the Swift API.
type Request struct {
Method string //"GET", "HEAD", "PUT", "POST" or "DELETE"
ContainerName string //empty for requests on accounts
@@ -80,7 +78,7 @@ type Request struct {
DrainResponseBody bool
}
-//URL returns the full URL for this request.
+// URL returns the full URL for this request.
func (r Request) URL(backend Backend, values url.Values) (string, error) {
uri, err := url.Parse(backend.EndpointURL())
if err != nil {
@@ -107,7 +105,7 @@ func (r Request) URL(backend Backend, values url.Values) (string, error) {
return uri.String(), nil
}
-//Do executes this request on the given Backend.
+// Do executes this request on the given Backend.
func (r Request) Do(backend Backend) (*http.Response, error) {
//build URL
var values url.Values
@@ -170,7 +168,7 @@ func (r Request) Do(backend Backend) (*http.Response, error) {
}
func drainResponseBody(r *http.Response) error {
- _, err := io.Copy(ioutil.Discard, r.Body)
+ _, err := io.Copy(io.Discard, r.Body)
if err != nil {
return err
}
@@ -178,7 +176,7 @@ func drainResponseBody(r *http.Response) error {
}
func collectResponseBody(r *http.Response) ([]byte, error) {
- buf, err := ioutil.ReadAll(r.Body)
+ buf, err := io.ReadAll(r.Body)
if err != nil {
return nil, err
}