From 40394bf84f4ea4d17c8dfaadd4c207bd253c4440 Mon Sep 17 00:00:00 2001 From: jaskaranSM <37726998+jaskaranSM@users.noreply.github.com> Date: Thu, 17 Sep 2020 16:06:29 +0530 Subject: [PATCH] JSON: replace json decoder with json unmarshal Previously it was causing an EOF error with json decoder. --- rpc/json2.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rpc/json2.go b/rpc/json2.go index 3febf7e..707b0dd 100644 --- a/rpc/json2.go +++ b/rpc/json2.go @@ -12,6 +12,7 @@ import ( "encoding/json" "errors" "io" + "io/ioutil" ) // ---------------------------------------------------------------------------- @@ -79,8 +80,13 @@ func (c clientResponse) decode(reply interface{}) error { // DecodeClientResponse decodes the response body of a client request into // the interface reply. func DecodeClientResponse(r io.Reader, reply interface{}) error { + b, err := ioutil.ReadAll(r) + if err != nil { + return err + } var c clientResponse - if err := json.NewDecoder(r).Decode(&c); err != nil { + err = json.Unmarshal(b, &c) + if err != nil { return err } return c.decode(reply)