Make the registry client more tolerant about HTTP status codes

Generally, all 2xx and 3xx codes should be treated as success.

Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
This commit is contained in:
Aaron Lehmann 2015-07-24 16:14:04 -07:00
parent a6ef6c0dc3
commit 6b4573225c
5 changed files with 40 additions and 52 deletions

View file

@ -10,6 +10,7 @@ import (
"sync"
"time"
"github.com/docker/distribution/registry/client"
"github.com/docker/distribution/registry/client/transport"
)
@ -209,7 +210,7 @@ func (th *tokenHandler) fetchToken(params map[string]string) (token string, err
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
if !client.SuccessStatus(resp.StatusCode) {
return "", fmt.Errorf("token auth attempt for registry: %s request failed with status: %d %s", req.URL, resp.StatusCode, http.StatusText(resp.StatusCode))
}