dont fail empty payload
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
55d2e88eca
commit
e94afcc70a
@ -85,7 +85,11 @@ func (c *jsonCodec) ReadBody(conn io.Reader, b interface{}) error {
|
||||
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 {
|
||||
|
@ -61,6 +61,8 @@ func (c *protoCodec) ReadBody(conn io.Reader, b interface{}) error {
|
||||
buf, err := ioutil.ReadAll(conn)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if buf == nil {
|
||||
return nil
|
||||
}
|
||||
return proto.Unmarshal(buf, m)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user