mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-26 02:09:47 +08:00
Set the request body to a new ReadCloser
This commit is contained in:
parent
59b1e8b0bc
commit
d06c15cae6
|
@ -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 ""
|
||||
|
|
Loading…
Reference in New Issue
Block a user