Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed to use more appropriate http status code for ResourceExhausted #580

Merged
merged 3 commits into from
Apr 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ func TestTimeout(t *testing.T) {
}
defer resp.Body.Close()

if got, want := resp.StatusCode, http.StatusRequestTimeout; got != want {
if got, want := resp.StatusCode, http.StatusGatewayTimeout; got != want {
t.Errorf("resp.StatusCode = %d; want %d", got, want)
}
}
Expand Down
7 changes: 4 additions & 3 deletions runtime/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

// HTTPStatusFromCode converts a gRPC error code into the corresponding HTTP response status.
// See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto
func HTTPStatusFromCode(code codes.Code) int {
switch code {
case codes.OK:
Expand All @@ -25,7 +26,7 @@ func HTTPStatusFromCode(code codes.Code) int {
case codes.InvalidArgument:
return http.StatusBadRequest
case codes.DeadlineExceeded:
return http.StatusRequestTimeout
return http.StatusGatewayTimeout
case codes.NotFound:
return http.StatusNotFound
case codes.AlreadyExists:
Expand All @@ -35,9 +36,9 @@ func HTTPStatusFromCode(code codes.Code) int {
case codes.Unauthenticated:
return http.StatusUnauthorized
case codes.ResourceExhausted:
return http.StatusServiceUnavailable
return http.StatusTooManyRequests
case codes.FailedPrecondition:
return http.StatusPreconditionFailed
return http.StatusBadRequest
case codes.Aborted:
return http.StatusConflict
case codes.OutOfRange:
Expand Down