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

Function closeResponse

pkg/credentials/assume_role.go:130–143  ·  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

128// Subsequently this allows golang http RoundTripper
129// to re-use the same connection for future requests.
130func closeResponse(resp *http.Response) {
131 // Callers should close resp.Body when done reading from it.
132 // If resp.Body is not closed, the Client's underlying RoundTripper
133 // (typically Transport) may not be able to re-use a persistent TCP
134 // connection to the server for a subsequent "keep-alive" request.
135 if resp != nil && resp.Body != nil {
136 // Drain any remaining Body and then close the connection.
137 // Without this closing connection would disallow re-using
138 // the same connection for future uses.
139 // - http://stackoverflow.com/a/17961593/4465767
140 io.Copy(io.Discard, resp.Body)
141 resp.Body.Close()
142 }
143}
144
145func getAssumeRoleCredentials(clnt *http.Client, endpoint string, opts STSAssumeRoleOptions) (AssumeRoleResponse, error) {
146 v := url.Values{}

Callers 1

getAssumeRoleCredentialsFunction · 0.70

Calls 1

CloseMethod · 0.45

Tested by

no test coverage detected