fix nil buf check

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
2021-04-12 19:17:01 +03:00
parent adbd069875
commit 8ecea8221f
2 changed files with 6 additions and 2 deletions

View File

@@ -54,6 +54,8 @@ func (c *protoCodec) ReadBody(conn io.Reader, b interface{}) error {
buf, err := ioutil.ReadAll(conn)
if err != nil {
return err
} else if len(buf) == 0 {
return nil
}
m.Data = buf
return nil
@@ -61,7 +63,7 @@ func (c *protoCodec) ReadBody(conn io.Reader, b interface{}) error {
buf, err := ioutil.ReadAll(conn)
if err != nil {
return err
} else if buf == nil {
} else if len(buf) == 0 {
return nil
}
return proto.Unmarshal(buf, m)