0
Fork 0
mirror of https://github.com/caddyserver/caddy.git synced 2024-12-23 22:27:38 -05:00

Set the request body to a new ReadCloser

This commit is contained in:
Carter 2016-08-10 10:36:16 -04:00
parent 59b1e8b0bc
commit d06c15cae6

View file

@ -1,6 +1,7 @@
package httpserver
import (
"bytes"
"io/ioutil"
"log"
"net"
@ -127,6 +128,9 @@ func NewReplacer(r *http.Request, rr *ResponseRecorder, emptyValue string) Repla
}
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 {
log.Printf("[WARNING] Cannot read request body %v", err)
return ""