From da9629d8dc5ce1fcaa9c8a19fb6bd46c1439000b Mon Sep 17 00:00:00 2001 From: Denis Makogon Date: Sat, 30 Sep 2017 00:52:23 +0300 Subject: [PATCH] Use STDIN as writer for encoding func's JSON input data instead of buffering --- api/agent/protocol/json.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/api/agent/protocol/json.go b/api/agent/protocol/json.go index 9a321eef0..bb55441cd 100644 --- a/api/agent/protocol/json.go +++ b/api/agent/protocol/json.go @@ -46,18 +46,12 @@ func (h *JSONProtocol) Dispatch(w io.Writer, req *http.Request) error { Headers: req.Header, Body: body.String(), } - b, err := json.Marshal(jin) + err := json.NewEncoder(h.in).Encode(&jin) if err != nil { // this shouldn't happen return respondWithError( w, fmt.Errorf("error marshalling JSONInput: %s", err.Error())) } - // TODO: write in chunks, how big should chunk be? - _, err = h.in.Write(b) - if err != nil { - return respondWithError( - w, fmt.Errorf("error writing JSON object to function's STDIN: %s", err.Error())) - } if rw, ok := w.(http.ResponseWriter); ok { // this has to be done for pulling out: