This repository was archived by the owner on Feb 1, 2021. It is now read-only.
close http response body to avoid potential memory leak #2176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It is an amazing thing for Swarm to use engine-api to contact with docker daemon. However in engine-api, after
Do a request
, sometimes it makes sure that response body is closed viaensureReaderClosed
:In some cases, engine api returns an
io.ReadCloser
like below:In the case above, Swarm should close the resp.body.
This PR did:
pullResponse
intopullResponseBody
to make it more readable, as this is a type ofio.ReadCloser
orhttp.Response.Body
Signed-off-by: Sun Hongliang [email protected]