From 999098b18758285e353208a040cc239360d6f6cd Mon Sep 17 00:00:00 2001 From: Robert Hencke Date: Sat, 30 Jul 2011 22:29:01 -0500 Subject: [PATCH] client: close HTTP responses when done. camput was failing for large amounts of files because there were too many open connections. Change-Id: I5a8b93070f14601ec0f4102634ed62fd83a021d8 --- lib/go/camli/client/upload.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/go/camli/client/upload.go b/lib/go/camli/client/upload.go index 3c3d629d7..cac9f709f 100644 --- a/lib/go/camli/client/upload.go +++ b/lib/go/camli/client/upload.go @@ -200,6 +200,9 @@ func (c *Client) Stat(dest chan<- blobref.SizedBlobRef, blobs []*blobref.BlobRef if err != nil { return fmt.Errorf("stat HTTP error: %v", err) } + if resp.Body != nil { + defer resp.Body.Close() + } if resp.StatusCode != 200 { return fmt.Errorf("stat response had http status %d", resp.StatusCode) @@ -246,6 +249,9 @@ func (c *Client) Upload(h *UploadHandle) (*PutResult, os.Error) { if err != nil { return errorf("stat http error: %v", err) } + if resp.Body != nil { + defer resp.Body.Close() + } if resp.StatusCode != 200 { return errorf("stat response had http status %d", resp.StatusCode) @@ -313,6 +319,9 @@ func (c *Client) Upload(h *UploadHandle) (*PutResult, os.Error) { if err != nil { return errorf("upload http error: %v", err) } + if resp.Body != nil { + defer resp.Body.Close() + } // check error from earlier copy if err := <-copyResult; err != nil {