Merge pull request #1696 from runcom/go1.6-lol

registry: do not use http.StatusTooManyRequests
This commit is contained in:
Richard Scothern 2016-05-04 09:45:18 -07:00
commit 9ec0d742d6
2 changed files with 8 additions and 2 deletions

View file

@ -71,7 +71,10 @@ var (
Message: "too many requests", Message: "too many requests",
Description: `Returned when a client attempts to contact a Description: `Returned when a client attempts to contact a
service too many times`, service too many times`,
HTTPStatusCode: http.StatusTooManyRequests, // FIXME: go1.5 doesn't export http.StatusTooManyRequests while
// go1.6 does. Update the hardcoded value to the constant once
// Docker updates golang version to 1.6.
HTTPStatusCode: 429,
}) })
) )

View file

@ -54,7 +54,10 @@ func parseHTTPErrorResponse(statusCode int, r io.Reader) error {
switch statusCode { switch statusCode {
case http.StatusUnauthorized: case http.StatusUnauthorized:
return errcode.ErrorCodeUnauthorized.WithMessage(detailsErr.Details) return errcode.ErrorCodeUnauthorized.WithMessage(detailsErr.Details)
case http.StatusTooManyRequests: // FIXME: go1.5 doesn't export http.StatusTooManyRequests while
// go1.6 does. Update the hardcoded value to the constant once
// Docker updates golang version to 1.6.
case 429:
return errcode.ErrorCodeTooManyRequests.WithMessage(detailsErr.Details) return errcode.ErrorCodeTooManyRequests.WithMessage(detailsErr.Details)
default: default:
return errcode.ErrorCodeUnknown.WithMessage(detailsErr.Details) return errcode.ErrorCodeUnknown.WithMessage(detailsErr.Details)