MCPcopy
hub / github.com/minio/minio-go / closeResponse

Function closeResponse

utils.go:135–148  ·  view source on GitHub ↗

closeResponse close non nil response with any response Body. convenient wrapper to drain any remaining data on response body. Subsequently this allows golang http RoundTripper to re-use the same connection for future requests.

(resp *http.Response)

Source from the content-addressed store, hash-verified

133// Subsequently this allows golang http RoundTripper
134// to re-use the same connection for future requests.
135func closeResponse(resp *http.Response) {
136 // Callers should close resp.Body when done reading from it.
137 // If resp.Body is not closed, the Client's underlying RoundTripper
138 // (typically Transport) may not be able to re-use a persistent TCP
139 // connection to the server for a subsequent "keep-alive" request.
140 if resp != nil && resp.Body != nil {
141 // Drain any remaining Body and then close the connection.
142 // Without this closing connection would disallow re-using
143 // the same connection for future uses.
144 // - http://stackoverflow.com/a/17961593/4465767
145 io.Copy(io.Discard, resp.Body)
146 resp.Body.Close()
147 }
148}
149
150var (
151 // Hex encoded string of nil sha256sum bytes.

Callers 15

CloseMethod · 0.70
startMethod · 0.70
GetObjectACLMethod · 0.70
BucketExistsMethod · 0.70
StatObjectMethod · 0.70
CreateSessionMethod · 0.70
appendObjectDoMethod · 0.70
PutObjectLegalHoldMethod · 0.70
GetObjectLegalHoldMethod · 0.70
executeMethodMethod · 0.70
doMakeBucketMethod · 0.70

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected