Revert "Version bump to etcd v3.2.11, grpc v1.7.5"
This commit is contained in:

committed by
GitHub

parent
0d42e742da
commit
4e8526dc6b
64
vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/context.go
generated
vendored
64
vendor/github.com/grpc-ecosystem/grpc-gateway/runtime/context.go
generated
vendored
@@ -9,23 +9,18 @@ import (
|
||||
"time"
|
||||
|
||||
"golang.org/x/net/context"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/codes"
|
||||
"google.golang.org/grpc/grpclog"
|
||||
"google.golang.org/grpc/metadata"
|
||||
"google.golang.org/grpc/status"
|
||||
)
|
||||
|
||||
// MetadataHeaderPrefix is the http prefix that represents custom metadata
|
||||
// parameters to or from a gRPC call.
|
||||
// MetadataHeaderPrefix is prepended to HTTP headers in order to convert them to
|
||||
// gRPC metadata for incoming requests processed by grpc-gateway
|
||||
const MetadataHeaderPrefix = "Grpc-Metadata-"
|
||||
|
||||
// MetadataPrefix is the prefix for grpc-gateway supplied custom metadata fields.
|
||||
const MetadataPrefix = "grpcgateway-"
|
||||
|
||||
// MetadataTrailerPrefix is prepended to gRPC metadata as it is converted to
|
||||
// HTTP headers in a response handled by grpc-gateway
|
||||
const MetadataTrailerPrefix = "Grpc-Trailer-"
|
||||
|
||||
const metadataGrpcTimeout = "Grpc-Timeout"
|
||||
|
||||
const xForwardedFor = "X-Forwarded-For"
|
||||
@@ -44,25 +39,25 @@ At a minimum, the RemoteAddr is included in the fashion of "X-Forwarded-For",
|
||||
except that the forwarded destination is not another HTTP service but rather
|
||||
a gRPC service.
|
||||
*/
|
||||
func AnnotateContext(ctx context.Context, mux *ServeMux, req *http.Request) (context.Context, error) {
|
||||
func AnnotateContext(ctx context.Context, req *http.Request) (context.Context, error) {
|
||||
var pairs []string
|
||||
timeout := DefaultContextTimeout
|
||||
if tm := req.Header.Get(metadataGrpcTimeout); tm != "" {
|
||||
var err error
|
||||
timeout, err = timeoutDecode(tm)
|
||||
if err != nil {
|
||||
return nil, status.Errorf(codes.InvalidArgument, "invalid grpc-timeout: %s", tm)
|
||||
return nil, grpc.Errorf(codes.InvalidArgument, "invalid grpc-timeout: %s", tm)
|
||||
}
|
||||
}
|
||||
|
||||
for key, vals := range req.Header {
|
||||
for _, val := range vals {
|
||||
// For backwards-compatibility, pass through 'authorization' header with no prefix.
|
||||
if strings.ToLower(key) == "authorization" {
|
||||
if key == "Authorization" {
|
||||
pairs = append(pairs, "authorization", val)
|
||||
continue
|
||||
}
|
||||
if h, ok := mux.incomingHeaderMatcher(key); ok {
|
||||
pairs = append(pairs, h, val)
|
||||
if strings.HasPrefix(key, MetadataHeaderPrefix) {
|
||||
pairs = append(pairs, key[len(MetadataHeaderPrefix):], val)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -90,11 +85,7 @@ func AnnotateContext(ctx context.Context, mux *ServeMux, req *http.Request) (con
|
||||
if len(pairs) == 0 {
|
||||
return ctx, nil
|
||||
}
|
||||
md := metadata.Pairs(pairs...)
|
||||
if mux.metadataAnnotator != nil {
|
||||
md = metadata.Join(md, mux.metadataAnnotator(ctx, req))
|
||||
}
|
||||
return metadata.NewOutgoingContext(ctx, md), nil
|
||||
return metadata.NewContext(ctx, metadata.Pairs(pairs...)), nil
|
||||
}
|
||||
|
||||
// ServerMetadata consists of metadata sent from gRPC server.
|
||||
@@ -150,38 +141,3 @@ func timeoutUnitToDuration(u uint8) (d time.Duration, ok bool) {
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// isPermanentHTTPHeader checks whether hdr belongs to the list of
|
||||
// permenant request headers maintained by IANA.
|
||||
// http://www.iana.org/assignments/message-headers/message-headers.xml
|
||||
func isPermanentHTTPHeader(hdr string) bool {
|
||||
switch hdr {
|
||||
case
|
||||
"Accept",
|
||||
"Accept-Charset",
|
||||
"Accept-Language",
|
||||
"Accept-Ranges",
|
||||
"Authorization",
|
||||
"Cache-Control",
|
||||
"Content-Type",
|
||||
"Cookie",
|
||||
"Date",
|
||||
"Expect",
|
||||
"From",
|
||||
"Host",
|
||||
"If-Match",
|
||||
"If-Modified-Since",
|
||||
"If-None-Match",
|
||||
"If-Schedule-Tag-Match",
|
||||
"If-Unmodified-Since",
|
||||
"Max-Forwards",
|
||||
"Origin",
|
||||
"Pragma",
|
||||
"Referer",
|
||||
"User-Agent",
|
||||
"Via",
|
||||
"Warning":
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user