fix http util (#995)

* fix http util

* fix type
pull/996/head
longxboy 4 years ago committed by GitHub
parent 5051609aef
commit af14c07762
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      internal/httputil/http.go

@ -9,6 +9,11 @@ import (
const (
baseContentType = "application"
// StatusClientClosed is non-standard http status code,
// which defined by nginx.
// https://httpstatus.in/499/
StatusClientClosed = 499
)
// ContentType returns the content-type with base prefix.
@ -62,6 +67,8 @@ func GRPCCodeFromStatus(code int) codes.Code {
return codes.Unavailable
case http.StatusGatewayTimeout:
return codes.DeadlineExceeded
case StatusClientClosed:
return codes.Canceled
}
return codes.Unknown
}
@ -73,7 +80,7 @@ func StatusFromGRPCCode(code codes.Code) int {
case codes.OK:
return http.StatusOK
case codes.Canceled:
return http.StatusRequestTimeout
return StatusClientClosed
case codes.Unknown:
return http.StatusInternalServerError
case codes.InvalidArgument:

Loading…
Cancel
Save