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:
parent
1f2e067f71
commit
7cad77bfc0
@ -192,6 +192,9 @@ func (h *httpTransportSocket) Recv(m *Message) error {
|
|||||||
if m == nil {
|
if m == nil {
|
||||||
return errors.New("message passed in is 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
|
// process http 1
|
||||||
if h.r.ProtoMajor == 1 {
|
if h.r.ProtoMajor == 1 {
|
||||||
@ -224,10 +227,6 @@ func (h *httpTransportSocket) Recv(m *Message) error {
|
|||||||
r.Body.Close()
|
r.Body.Close()
|
||||||
m.Body = b
|
m.Body = b
|
||||||
|
|
||||||
if m.Header == nil {
|
|
||||||
m.Header = make(map[string]string, len(r.Header))
|
|
||||||
}
|
|
||||||
|
|
||||||
// set headers
|
// set headers
|
||||||
for k, v := range r.Header {
|
for k, v := range r.Header {
|
||||||
if len(v) > 0 {
|
if len(v) > 0 {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user