Skip to content
This repository was archived by the owner on Aug 30, 2024. It is now read-only.

Adjust HTTPError to read response body before it is closed #361

Merged
merged 2 commits into from
May 27, 2021

Conversation

nathanpotter
Copy link

@nathanpotter nathanpotter commented May 26, 2021

@nathanpotter nathanpotter requested a review from ammario May 26, 2021 22:41
Copy link
Member

@ammario ammario left a comment

Choose a reason for hiding this comment

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

Nice bug de-risk

@@ -36,7 +36,7 @@ type APIErrorMsg struct {
// an *APIError.
func NewHTTPError(resp *http.Response) *HTTPError {
var buf bytes.Buffer
_, err := io.CopyN(&buf, resp.Body, 1<<20)
_, err := io.Copy(&buf, resp.Body)
Copy link
Member

Choose a reason for hiding this comment

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

👍 nice simplification. I can't think of a case where the error body would be excessively large.

@nathanpotter nathanpotter merged commit 2d470e4 into master May 27, 2021
@nathanpotter nathanpotter deleted the httperr branch May 27, 2021 00:42
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