From ccfc0efd979751bbc151455e20b48b7a30976261 Mon Sep 17 00:00:00 2001 From: iamqizhao Date: Wed, 2 Sep 2015 16:52:46 -0700 Subject: [PATCH] check content-type == application/grpc --- transport/http_util.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/transport/http_util.go b/transport/http_util.go index ac3c4755..281819c7 100644 --- a/transport/http_util.go +++ b/transport/http_util.go @@ -140,6 +140,11 @@ func newHPACKDecoder() *hpackDecoder { d := &hpackDecoder{} d.h = hpack.NewDecoder(http2InitHeaderTableSize, func(f hpack.HeaderField) { switch f.Name { + case "content-type": + if !strings.Contains(f.Value, "application/grpc") { + d.err = StreamErrorf(codes.FailedPrecondition, "transport: received the unexpected header") + return + } case "grpc-status": code, err := strconv.Atoi(f.Value) if err != nil {