server/grpc: avoid panic in case of nil Header (#1303)

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2020-03-05 17:45:31 +03:00
parent 6ebe79538a
commit b48f919b7b

View File

@ -178,6 +178,11 @@ func (g *grpcServer) createSubHandler(sb *subscriber, opts server.Options) broke
}()
msg := p.Message()
// if we don't ave headers, create empty map
if msg.Header == nil {
msg.Header = make(map[string]string)
}
ct := msg.Header["Content-Type"]
if len(ct) == 0 {
msg.Header["Content-Type"] = defaultContentType