mirror of
https://github.com/caddyserver/caddy.git
synced 2024-11-29 12:16:16 +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
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
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 ""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user