Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure response is fully consumed #1813

Merged
merged 1 commit into from
Oct 4, 2023
Merged

Conversation

mitar
Copy link
Contributor

@mitar mitar commented Oct 4, 2023

This fully consumes a response body. I have learned through some other experiences that this is important to do in Go. This is especially useful if nil is provided as v, because then response body is just closed. But also when JSON decoder does not decode all data (and there is some extra bytes after the decoded JSON response) - JSON decoder does not necessary consume full input, just enough that v is decoded. Any errors returned by io.Copy are ignored on purpose.

See similar thing in go-github library: google/go-github#317

Copy link
Member

@svanharmelen svanharmelen left a comment

Choose a reason for hiding this comment

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

I'll take it, thanks 👍🏻

@svanharmelen svanharmelen merged commit 285184d into xanzy:master Oct 4, 2023
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants