From 796bcd78261a9b592bf5b572be8504a0e4eba2a7 Mon Sep 17 00:00:00 2001 From: vminkobin Date: Tue, 18 Oct 2022 14:05:24 +0400 Subject: [PATCH] Fix issue with body json decoder. Decoder will add "\n" at the end of the body. This can produce issues when sending signed requests. --- client/client_execute.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/client/client_execute.go b/client/client_execute.go index f3d69c1..c971e0e 100644 --- a/client/client_execute.go +++ b/client/client_execute.go @@ -138,9 +138,16 @@ func (r *Request) metricsEnabled() bool { } func GetBody(body interface{}) (buf io.ReadWriter, err error) { - if body != nil { - buf = new(bytes.Buffer) - err = json.NewEncoder(buf).Encode(body) + if body == nil { + return } + + var bs []byte + bs, err = json.Marshal(body) + if err != nil { + return + } + + buf = bytes.NewBuffer(bs) return }