diff --git a/cmd/utils.go b/cmd/utils.go index 71e238f..fd59f82 100644 --- a/cmd/utils.go +++ b/cmd/utils.go @@ -290,6 +290,10 @@ func (s *rewindableByteReader) Rewind() (int64, error) { return s.data.Seek(0, io.SeekStart) } +func discard(reader io.Reader) { + io.Copy(io.Discard, reader) +} + type signingTransport struct { base http.RoundTripper tokenId string @@ -332,6 +336,10 @@ func (s signingTransport) RoundTrip(req *http.Request) (*http.Response, error) { tee = io.TeeReader(req.Body, body) ) + defer req.Body.Close() + defer discard(tee) + defer discard(body) + for { numRead, err := tee.Read(hashBuf) if numRead > 0 {