[ARVADOS] updated: dd476af362769999d6317bc48a84c35d4d340377

git at public.curoverse.com git at public.curoverse.com
Mon Dec 29 13:49:54 EST 2014


Summary of changes:
 sdk/go/keepclient/support.go | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

       via  dd476af362769999d6317bc48a84c35d4d340377 (commit)
      from  f69395a08509cc8c664c3256019d4d3cdb67db86 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.


commit dd476af362769999d6317bc48a84c35d4d340377
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date:   Mon Dec 29 13:51:20 2014 -0500

    4869: Based on Go documentation, don't set a body ReadCloser on the request
    when body length is 0.

diff --git a/sdk/go/keepclient/support.go b/sdk/go/keepclient/support.go
index 1f2a976..c03578c 100644
--- a/sdk/go/keepclient/support.go
+++ b/sdk/go/keepclient/support.go
@@ -104,11 +104,17 @@ func (this KeepClient) uploadToKeepServer(host string, hash string, body io.Read
 		return
 	}
 
-	if expectedLength > -1 {
-		req.ContentLength = expectedLength
-	}
-	if expectedLength == 0 {
-		defer body.Close()
+	req.ContentLength = expectedLength
+	if expectedLength > 0 {
+		// http.Client.Do will close the body ReadCloser when it is
+		// done with it.
+		req.Body = body
+	} else {
+		// "For client requests, a value of 0 means unknown if Body is
+		// not nil."  In this case we do want the body to be empty, so
+		// don't set req.Body.  However, we still need to close the
+		// body ReadCloser.
+		body.Close()
 	}
 
 	req.Header.Add("Authorization", fmt.Sprintf("OAuth2 %s", this.Arvados.ApiToken))
@@ -118,8 +124,6 @@ func (this KeepClient) uploadToKeepServer(host string, hash string, body io.Read
 		req.Header.Add(X_Keep_Desired_Replicas, fmt.Sprint(this.Want_replicas))
 	}
 
-	req.Body = body
-
 	var resp *http.Response
 	if resp, err = this.Client.Do(req); err != nil {
 		log.Printf("[%v] Upload failed %v error: %v", requestId, url, err.Error())

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list