diff --git a/modules/http_proxy_js_request.go b/modules/http_proxy_js_request.go index 63a97ee2..17741d3f 100644 --- a/modules/http_proxy_js_request.go +++ b/modules/http_proxy_js_request.go @@ -1,6 +1,7 @@ package modules import ( + "bytes" "fmt" "io/ioutil" "net/http" @@ -61,6 +62,8 @@ func (j *JSRequest) ReadBody() string { } j.Body = string(raw) + // reset the request body to the original unread state + j.req.Body = ioutil.NopCloser(bytes.NewBuffer(raw)) return j.Body } diff --git a/modules/http_proxy_js_response.go b/modules/http_proxy_js_response.go index 83dfc069..ea372e99 100644 --- a/modules/http_proxy_js_response.go +++ b/modules/http_proxy_js_response.go @@ -1,6 +1,7 @@ package modules import ( + "bytes" "fmt" "io/ioutil" "net/http" @@ -99,6 +100,8 @@ func (j *JSResponse) ReadBody() string { j.Body = string(raw) j.bodyRead = true + // reset the request body to the original unread state + j.resp.Body = ioutil.NopCloser(bytes.NewBuffer(raw)) return j.Body }