Merge pull request #10471 from jlhawn/token_auth_header

Fix token basic auth header issue
This commit is contained in:
Tibor Vass 2015-01-31 19:51:50 -05:00
commit cbda817ec3
2 changed files with 6 additions and 2 deletions

View file

@ -128,6 +128,8 @@ func (r *Session) HeadV2ImageBlob(ep *Endpoint, imageName, sumType, sum string,
case res.StatusCode >= 200 && res.StatusCode < 400:
// return something indicating no push needed
return true, nil
case res.StatusCode == 401:
return false, errLoginRequired
case res.StatusCode == 404:
// return something indicating blob push needed
return false, nil

View file

@ -51,10 +51,12 @@ func getToken(username, password string, params map[string]string, registryEndpo
reqParams.Add("scope", scopeField)
}
if username != "" {
reqParams.Add("account", username)
req.SetBasicAuth(username, password)
}
req.URL.RawQuery = reqParams.Encode()
req.SetBasicAuth(username, password)
resp, err := client.Do(req)
if err != nil {