check content-type == application/grpc

This commit is contained in:
iamqizhao
2015-09-02 16:52:46 -07:00
parent 4bd040ce23
commit ccfc0efd97

View File

@ -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 {