From 0103f0d62ac95ce904bd269575be51aea4224c97 Mon Sep 17 00:00:00 2001 From: Clayton Coleman Date: Wed, 26 Jul 2017 21:43:24 -0400 Subject: [PATCH] Update generic errors with the new http package codes All of these errors are now part of the standard HTTP method. Formalize those into our error types and remove duplication and unclear separation. Kubernetes-commit: d3be1ac92eb644e284915a55fe67942c33f88d4c --- rest/request.go | 2 +- rest/request_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/rest/request.go b/rest/request.go index b9098404..5e245aeb 100644 --- a/rest/request.go +++ b/rest/request.go @@ -889,7 +889,7 @@ func isTextResponse(resp *http.Response) bool { func checkWait(resp *http.Response) (int, bool) { switch r := resp.StatusCode; { // any 500 error code and 429 can trigger a wait - case r == errors.StatusTooManyRequests, r >= 500: + case r == http.StatusTooManyRequests, r >= 500: default: return 0, false } diff --git a/rest/request_test.go b/rest/request_test.go index fa016dfe..0691fc72 100755 --- a/rest/request_test.go +++ b/rest/request_test.go @@ -1130,7 +1130,7 @@ func TestCheckRetryClosesBody(t *testing.T) { return } w.Header().Set("Retry-After", "1") - http.Error(w, "Too many requests, please try again later.", apierrors.StatusTooManyRequests) + http.Error(w, "Too many requests, please try again later.", http.StatusTooManyRequests) })) defer testServer.Close() @@ -1204,7 +1204,7 @@ func TestCheckRetryHandles429And5xx(t *testing.T) { return } w.Header().Set("Retry-After", "0") - w.WriteHeader([]int{apierrors.StatusTooManyRequests, 500, 501, 504}[count]) + w.WriteHeader([]int{http.StatusTooManyRequests, 500, 501, 504}[count]) count++ })) defer testServer.Close() @@ -1234,7 +1234,7 @@ func BenchmarkCheckRetryClosesBody(b *testing.B) { return } w.Header().Set("Retry-After", "0") - w.WriteHeader(apierrors.StatusTooManyRequests) + w.WriteHeader(http.StatusTooManyRequests) })) defer testServer.Close()