Skip to content

Commit d813f66

Browse files
committed
Issue #20: do not unmarshal empty response body
1 parent 47f2bfd commit d813f66

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

request.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,11 @@ func Send(options *Options, results interface{}) (*Content, error) {
237237
return nil, errors.WithStack(err)
238238
}
239239
log.Tracef("Response body in %s: %s", time.Since(start), resContent.LogString(uint64(options.ResponseBodyLogSize)))
240-
err = json.Unmarshal(resContent.Data, results)
241-
if err != nil {
242-
return resContent, errors.JSONUnmarshalError.WrapIfNotMe(err)
240+
if resContent.Length > 0 {
241+
err = json.Unmarshal(resContent.Data, results)
242+
if err != nil {
243+
return resContent, errors.JSONUnmarshalError.WrapIfNotMe(err)
244+
}
243245
}
244246
return resContent, nil
245247
}

0 commit comments

Comments
 (0)