Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants