dont fail empty payload
Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
parent
1c774699fe
commit
d274240d1d
3
yaml.go
3
yaml.go
@ -57,6 +57,9 @@ func (c *yamlCodec) ReadBody(conn io.Reader, b interface{}) error {
|
||||
buf, err := ioutil.ReadAll(conn)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if buf == nil {
|
||||
// not needed but similar changes in all codecs
|
||||
return nil
|
||||
}
|
||||
|
||||
return yaml.Unmarshal(buf, b)
|
||||
|
18
yaml_test.go
Normal file
18
yaml_test.go
Normal file
@ -0,0 +1,18 @@
|
||||
package yaml
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestReadBody(t *testing.T) {
|
||||
s := &struct {
|
||||
Name string
|
||||
}{}
|
||||
c := NewCodec()
|
||||
b := bytes.NewReader(nil)
|
||||
err := c.ReadBody(b, s)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user