dont fail empty payload

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-04-12 16:43:49 +03:00
parent 55d2e88eca
commit e94afcc70a
2 changed files with 7 additions and 1 deletions

View File

@ -85,7 +85,11 @@ func (c *jsonCodec) ReadBody(conn io.Reader, b interface{}) error {
return nil return nil
} }
return json.NewDecoder(conn).Decode(b) err := json.NewDecoder(conn).Decode(b)
if err == io.EOF {
return nil
}
return err
} }
func (c *jsonCodec) Write(conn io.Writer, m *codec.Message, b interface{}) error { func (c *jsonCodec) Write(conn io.Writer, m *codec.Message, b interface{}) error {

View File

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