Merge branch 'master' into 1885-keep-proxy refs #1885
[arvados.git] / sdk / go / src / arvados.org / keepclient / support.go
index d0ea9670fe22f819471d947808ec22c9b1e132d5..ef4a8e1133b8674dc84d696cc01b04ae1e6269b4 100644 (file)
@@ -33,12 +33,15 @@ func (this *KeepClient) discoverKeepServers() error {
        var req *http.Request
        var err error
 
-       if req, err = http.NewRequest("GET", fmt.Sprintf("https://%s/arvados/v1/keep_services/accessible", this.ApiServer), nil); err != nil {
+       if req, err = http.NewRequest("GET", fmt.Sprintf("https://%s/arvados/v1/keep_services/accessible?format=json", this.ApiServer), nil); err != nil {
                return err
        }
 
        // Add api token header
        req.Header.Add("Authorization", fmt.Sprintf("OAuth2 %s", this.ApiToken))
+       if this.External {
+               req.Header.Add("X-External-Client", "1")
+       }
 
        // Make the request
        var resp *http.Response
@@ -183,6 +186,7 @@ func (this KeepClient) uploadToKeepServer(host string, hash string, body io.Read
        var resp *http.Response
        if resp, err = this.Client.Do(req); err != nil {
                upload_status <- uploadStatus{err, url, 0, 0}
+               body.Close()
                return
        }
 
@@ -228,7 +232,6 @@ func (this KeepClient) putReplicas(
                                next_server += 1
                                active += 1
                        } else {
-                               fmt.Print(active)
                                if active == 0 {
                                        return (this.Want_replicas - remaining_replicas), InsufficientReplicasError
                                } else {
@@ -248,7 +251,7 @@ func (this KeepClient) putReplicas(
                                status.url, status.err)
                }
                active -= 1
-               log.Printf("Upload status %v %v %v", status.statusCode, remaining_replicas, active)
+               log.Printf("Upload status code: %v remaining replicas: %v active: %v", status.statusCode, remaining_replicas, active)
        }
 
        return this.Want_replicas, nil