From c82a9a817f4e565586b3e3378595e8274f860391 Mon Sep 17 00:00:00 2001 From: Matt Moore Date: Thu, 9 Jul 2015 20:56:23 -0700 Subject: [PATCH] Add the X-Docker-Token header to the /v1/search requests. By adding this header AuthTransport will add Basic authentication to the request and allow 'docker search' results to include private images. Signed-off-by: Matt Moore --- docs/session.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/session.go b/docs/session.go index 77f6d20b3..7d57f1b8d 100644 --- a/docs/session.go +++ b/docs/session.go @@ -676,7 +676,14 @@ func shouldRedirect(response *http.Response) bool { func (r *Session) SearchRepositories(term string) (*SearchResults, error) { logrus.Debugf("Index server: %s", r.indexEndpoint) u := r.indexEndpoint.VersionString(1) + "search?q=" + url.QueryEscape(term) - res, err := r.client.Get(u) + + req, err := http.NewRequest("GET", u, nil) + if err != nil { + return nil, fmt.Errorf("Error while getting from the server: %v", err) + } + // Have the AuthTransport send authentication, when logged in. + req.Header.Set("X-Docker-Token", "true") + res, err := r.client.Do(req) if err != nil { return nil, err }