client: close HTTP responses when done.

camput was failing for large amounts of files because there
were too many open connections.

Change-Id: I5a8b93070f14601ec0f4102634ed62fd83a021d8
This commit is contained in:
Robert Hencke 2011-07-30 22:29:01 -05:00
parent 85d2472b34
commit 999098b187
1 changed files with 9 additions and 0 deletions

View File

@ -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 {