Commit d06c15ca authored by Carter's avatar Carter

Set the request body to a new ReadCloser

parent 59b1e8b0
package httpserver package httpserver
import ( import (
"bytes"
"io/ioutil" "io/ioutil"
"log" "log"
"net" "net"
...@@ -127,6 +128,9 @@ func NewReplacer(r *http.Request, rr *ResponseRecorder, emptyValue string) Repla ...@@ -127,6 +128,9 @@ func NewReplacer(r *http.Request, rr *ResponseRecorder, emptyValue string) Repla
} }
body, err := ioutil.ReadAll(r.Body) body, err := ioutil.ReadAll(r.Body)
// Create a new ReadCloser to keep the body from being drained.
r.Body = ioutil.NopCloser(bytes.NewBuffer(body))
if err != nil { if err != nil {
log.Printf("[WARNING] Cannot read request body %v", err) log.Printf("[WARNING] Cannot read request body %v", err)
return "" return ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment