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
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if req.ContentLength != 0 {
|
bb := new(bytes.Buffer)
|
||||||
|
_, err = bb.ReadFrom(req.Body)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
reqData := bb.String()
|
||||||
|
if reqData != "" {
|
||||||
_, err := io.WriteString(h.in, `"body": `)
|
_, err := io.WriteString(h.in, `"body": `)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// this shouldn't happen
|
// this shouldn't happen
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
bb := new(bytes.Buffer)
|
err = stdin.Encode(reqData)
|
||||||
_, err = bb.ReadFrom(req.Body)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
err = stdin.Encode(bb.String())
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user