1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-11-24 08:02:32 +02:00

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

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Vasiliy Tolstov 2020-03-05 17:45:31 +03:00 committed by GitHub
parent ce2ba71002
commit d807dac2a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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