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

@ -154,10 +154,11 @@ func (hrs *httpReadSeeker) reader() (io.Reader, error) {
return nil, err
}
switch {
case resp.StatusCode == 200:
// Normally would use client.SuccessStatus, but that would be a cyclic
// import
if resp.StatusCode >= 200 && resp.StatusCode <= 399 {
hrs.rc = resp.Body
default:
} else {
defer resp.Body.Close()
return nil, fmt.Errorf("unexpected status resolving reader: %v", resp.Status)
}