diff options
| author | Stefan Majewsky <majewsky@gmx.net> | 2018-02-11 12:23:16 +0100 |
|---|---|---|
| committer | Stefan Majewsky <majewsky@gmx.net> | 2018-02-11 12:23:16 +0100 |
| commit | 403359114bf971f037e2737b43e2734a89df9f0a (patch) | |
| tree | 757c4a2008bb4dabc0f8072b6b357f58308065a7 /request.go | |
| parent | 9a8ec45e50647e134e5a6e14c3738d6627298b97 (diff) | |
| download | go-schwift-403359114bf971f037e2737b43e2734a89df9f0a.tar.gz | |
ensure that response body is drained
Diffstat (limited to 'request.go')
| -rw-r--r-- | request.go | 9 |
1 files changed, 8 insertions, 1 deletions
@@ -70,6 +70,9 @@ type Request struct { //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 bool } //URL returns the full URL for this request. @@ -144,7 +147,11 @@ func (r Request) do(client *gophercloud.ServiceClient, afterReauth bool) (*http. } for _, code := range r.ExpectStatusCodes { if code == resp.StatusCode { - return resp, nil + var err error + if r.DrainResponseBody || resp.StatusCode == 204 { + err = drainResponseBody(resp) + } + return resp, err } } |
