Skip to content

Commit 6b93d48

Browse files
shogo82148bmoffatt
andauthored
reuse runtimeAPIClient.buffer (#325)
Co-authored-by: Bryan Moffatt <[email protected]>
1 parent 308c17f commit 6b93d48

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

lambda/runtime_api_client.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,15 @@ func (c *runtimeAPIClient) next() (*invoke, error) {
9090
return nil, fmt.Errorf("failed to GET %s: got unexpected status code: %d", url, resp.StatusCode)
9191
}
9292

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

9999
return &invoke{
100100
id: resp.Header.Get(headerAWSRequestID),
101-
payload: body.Bytes(),
101+
payload: c.buffer.Bytes(),
102102
headers: resp.Header,
103103
client: c,
104104
}, nil

0 commit comments

Comments
 (0)