mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Read request body and see if it's not empty then decide whether write it or not
This commit is contained in:
@@ -37,19 +37,19 @@ func (h *JSONProtocol) DumpJSON(w io.Writer, req *http.Request) error {
|
||||
return err
|
||||
}
|
||||
|
||||
if req.ContentLength != 0 {
|
||||
_, err := io.WriteString(h.in, `"body": `)
|
||||
if err != nil {
|
||||
// this shouldn't happen
|
||||
return err
|
||||
}
|
||||
bb := new(bytes.Buffer)
|
||||
_, err = bb.ReadFrom(req.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = stdin.Encode(bb.String())
|
||||
reqData := bb.String()
|
||||
if reqData != "" {
|
||||
_, err := io.WriteString(h.in, `"body": `)
|
||||
if err != nil {
|
||||
// this shouldn't happen
|
||||
return err
|
||||
}
|
||||
err = stdin.Encode(reqData)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user