Skip to content

Conversation

@grey3228
Copy link

Hello!

In (*httpSourceHandler).resolveMetadata method there is a potential resp.Body leak in case when response status code is not valid (< 200 or >= 400). Also resp.Body is not closed before exiting if status code is okay.

This PR adds resp.Body closing before exiting from resolveMetadata method.

In (*httpSourceHandler).resolveMetadata method there is
a potential resp.Body leak in case when response status code is not
valid (< 200 or >= 400). Also resp.Body is not closed before exiting
if status code is okay.

This commit adds resp.Body closing before exiting from resolveMetadata
method.

Signed-off-by: Mikhail Dmitrichenko <[email protected]>
Copy link
Member

@tonistiigi tonistiigi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was reading the docs for this

If the returned error is nil, the Response will contain a non-nil Body which the user is expected to close. If the Body is not both read to EOF and closed, the Client's underlying RoundTripper (typically Transport) may not be able to re-use a persistent TCP connection to the server for a subsequent "keep-alive" request.

So it looks like we should not only close but also read to io.Discard. Not sure if it makes any difference in practice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants