Skip to content

Commit

Permalink
Use canonical header form in default header matcher. (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha authored and tmc committed Apr 19, 2017
1 parent 893772d commit 55d0969
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions runtime/mux.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package runtime

import (
"fmt"
"net/http"
"net/textproto"
"strings"

"golang.org/x/net/context"

"github.com/golang/protobuf/proto"
"golang.org/x/net/context"
"google.golang.org/grpc/metadata"
)

Expand Down Expand Up @@ -48,8 +47,9 @@ type HeaderMatcherFunc func(string) (string, bool)
// keys (as specified by the IANA) to gRPC context with grpcgateway- prefix. HTTP headers that start with
// 'Grpc-Metadata-' are mapped to gRPC metadata after removing prefix 'Grpc-Metadata-'.
func DefaultHeaderMatcher(key string) (string, bool) {
key = textproto.CanonicalMIMEHeaderKey(key)
if isPermanentHTTPHeader(key) {
return strings.ToLower(fmt.Sprintf("%s%s", MetadataPrefix, key)), true
return MetadataPrefix + key, true
} else if strings.HasPrefix(key, MetadataHeaderPrefix) {
return key[len(MetadataHeaderPrefix):], true
}
Expand Down

0 comments on commit 55d0969

Please sign in to comment.