diff options
Diffstat (limited to 'request.go')
| -rw-r--r-- | request.go | 24 |
1 files changed, 12 insertions, 12 deletions
@@ -65,16 +65,16 @@ func cloneRequestOptions(orig *RequestOptions, additional Headers) *RequestOptio // 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 - ObjectName string //empty for requests on accounts/containers + Method string // "GET", "HEAD", "PUT", "POST" or "DELETE" + ContainerName string // empty for requests on accounts + ObjectName string // empty for requests on accounts/containers Options *RequestOptions Body io.Reader - //ExpectStatusCodes can be left empty to disable this check, otherwise - //schwift.UnexpectedStatusCodeError may be returned. + // ExpectStatusCodes can be left empty to disable this check, otherwise + // schwift.UnexpectedStatusCodeError may be returned. ExpectStatusCodes []int - //DrainResponseBody can be set if the caller is not interested in the - //response body. This is implied for Response.StatusCode == 204. + // DrainResponseBody can be set if the caller is not interested in the + // response body. This is implied for Response.StatusCode == 204. DrainResponseBody bool } @@ -107,7 +107,7 @@ func (r Request) URL(backend Backend, values url.Values) (string, error) { // Do executes this request on the given Backend. func (r Request) Do(backend Backend) (*http.Response, error) { - //build URL + // build URL var values url.Values if r.Options != nil { values = r.Options.Values @@ -117,7 +117,7 @@ func (r Request) Do(backend Backend) (*http.Response, error) { return nil, err } - //build request + // build request req, err := http.NewRequest(r.Method, uri, r.Body) if err != nil { return nil, err @@ -140,9 +140,9 @@ func (r Request) Do(backend Backend) (*http.Response, error) { return nil, err } - //return success if error code matches expectation + // return success if error code matches expectation if len(r.ExpectStatusCodes) == 0 { - //check disabled -> return response unaltered + // check disabled -> return response unaltered return resp, nil } for _, code := range r.ExpectStatusCodes { @@ -155,7 +155,7 @@ func (r Request) Do(backend Backend) (*http.Response, error) { } } - //unexpected status code -> generate error + // unexpected status code -> generate error buf, err := collectResponseBody(resp) if err != nil { return nil, err |
