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

@ -61,3 +61,9 @@ func handleErrorResponse(resp *http.Response) error {
}
return &UnexpectedHTTPStatusError{Status: resp.Status}
}
// SuccessStatus returns true if the argument is a successful HTTP response
// code (in the range 200 - 399 inclusive).
func SuccessStatus(status int) bool {
return status >= 200 && status <= 399
}