From 3c85e9390e2d5fac418e03bac376eb1618487f3c Mon Sep 17 00:00:00 2001 From: shin- Date: Thu, 25 Apr 2013 10:12:41 -0700 Subject: [PATCH] Added X-Docker-Token header to initial index requests --- registry.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/registry.go b/registry.go index 45a9d3bbfc..af69c58adb 100644 --- a/registry.go +++ b/registry.go @@ -239,7 +239,7 @@ func (graph *Graph) PullRepository(stdout io.Writer, remote, askedTag string, re client := graph.getHttpClient() fmt.Fprintf(stdout, "Pulling repository %s\r\n", remote) - repositoryTarget := INDEX_ENDPOINT + "/repositories/" + remote + "/checksums" + repositoryTarget := INDEX_ENDPOINT + "/repositories/" + remote + "/checksums/" req, err := http.NewRequest("GET", repositoryTarget, nil) if err != nil { @@ -248,6 +248,7 @@ func (graph *Graph) PullRepository(stdout io.Writer, remote, askedTag string, re if authConfig != nil { req.SetBasicAuth(authConfig.Username, authConfig.Password) } + req.Header.Set("X-Docker-Token", "true") res, err := client.Do(req) if err != nil { @@ -461,6 +462,7 @@ func (graph *Graph) PushRepository(stdout io.Writer, remote string, localRepo Re return err } req.SetBasicAuth(authConfig.Username, authConfig.Password) + req.Header.Set("X-Docker-Token", "true") res, err := client.Do(req) if err != nil { return err @@ -473,6 +475,7 @@ func (graph *Graph) PushRepository(stdout io.Writer, remote string, localRepo Re return err } req.SetBasicAuth(authConfig.Username, authConfig.Password) + req.Header.Set("X-Docker-Token", "true") res, err = client.Do(req) if err != nil { return err @@ -488,6 +491,7 @@ func (graph *Graph) PushRepository(stdout io.Writer, remote string, localRepo Re if res.Header.Get("X-Docker-Token") != "" { token = res.Header["X-Docker-Token"] } else { + Debugf("Response headers:\n %s\n", res.Header) return fmt.Errorf("Index response didn't contain an access token") } if res.Header.Get("X-Docker-Endpoints") != "" {