Don't read unless we have b
This commit is contained in:
parent
617db003d4
commit
9ce9977d21
@ -18,13 +18,13 @@ func (c *Codec) ReadHeader(m *codec.Message, t codec.MessageType) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Codec) ReadBody(b interface{}) error {
|
func (c *Codec) ReadBody(b interface{}) error {
|
||||||
|
if b == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
buf, err := ioutil.ReadAll(c.Conn)
|
buf, err := ioutil.ReadAll(c.Conn)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if b == nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return proto.Unmarshal(buf, b.(proto.Message))
|
return proto.Unmarshal(buf, b.(proto.Message))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user