fix nil buf check

Signed-off-by: Vasiliy Tolstov <v.tolstov@unistack.org>
This commit is contained in:
Василий Толстов 2021-04-12 19:19:08 +03:00
parent 996aa7a25f
commit 09cf9b2007

4
xml.go
View File

@ -23,7 +23,7 @@ func (c *xmlCodec) Marshal(b interface{}) ([]byte, error) {
} }
func (c *xmlCodec) Unmarshal(b []byte, v interface{}) error { func (c *xmlCodec) Unmarshal(b []byte, v interface{}) error {
if b == nil { if len(b) == 0 {
return nil return nil
} }
switch m := v.(type) { switch m := v.(type) {
@ -49,6 +49,8 @@ func (c *xmlCodec) 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 len(buf) == 0 {
return nil
} }
m.Data = buf m.Data = buf
return nil return nil