From 6141344e5fbd001d9a2b75e47d99542d729b39fc Mon Sep 17 00:00:00 2001 From: Denis Makogon Date: Sat, 7 Oct 2017 02:33:43 +0300 Subject: [PATCH] Error before sending json object if something bad happend with reading a request body --- api/agent/protocol/json.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/agent/protocol/json.go b/api/agent/protocol/json.go index e249d6c6c..8d934159d 100644 --- a/api/agent/protocol/json.go +++ b/api/agent/protocol/json.go @@ -37,6 +37,9 @@ func (h *JSONProtocol) DumpJSON(req *http.Request) error { stdin := json.NewEncoder(h.in) bb := new(bytes.Buffer) _, err := bb.ReadFrom(req.Body) + if err != nil { + return err + } err = writeString(err, h.in, "{") err = writeString(err, h.in, `"body":`) err = stdin.Encode(bb.String())