Skip to content

Commit

Permalink
reuse runtimeAPIClient.buffer (#325)
Browse files Browse the repository at this point in the history
Co-authored-by: Bryan Moffatt <[email protected]>
  • Loading branch information
shogo82148 and bmoffatt authored Oct 3, 2020
1 parent 308c17f commit 6b93d48
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lambda/runtime_api_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ func (c *runtimeAPIClient) next() (*invoke, error) {
return nil, fmt.Errorf("failed to GET %s: got unexpected status code: %d", url, resp.StatusCode)
}

body := bytes.NewBuffer(nil)
_, err = io.Copy(body, resp.Body)
c.buffer.Reset()
_, err = c.buffer.ReadFrom(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read the invoke payload: %v", err)
}

return &invoke{
id: resp.Header.Get(headerAWSRequestID),
payload: body.Bytes(),
payload: c.buffer.Bytes(),
headers: resp.Header,
client: c,
}, nil
Expand Down

0 comments on commit 6b93d48

Please sign in to comment.