1
0
mirror of https://github.com/go-micro/go-micro.git synced 2024-12-24 10:07:04 +02:00

Initialize header to prevent assignment to entry in nil map error (#1282)

Co-authored-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Pieter Voorwinden 2020-03-02 17:17:26 +01:00 committed by GitHub
parent 1f2e067f71
commit 7cad77bfc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -192,6 +192,9 @@ func (h *httpTransportSocket) Recv(m *Message) error {
if m == nil {
return errors.New("message passed in is nil")
}
if m.Header == nil {
m.Header = make(map[string]string, len(h.r.Header))
}
// process http 1
if h.r.ProtoMajor == 1 {
@ -224,10 +227,6 @@ func (h *httpTransportSocket) Recv(m *Message) error {
r.Body.Close()
m.Body = b
if m.Header == nil {
m.Header = make(map[string]string, len(r.Header))
}
// set headers
for k, v := range r.Header {
if len(v) > 0 {