fix: resetting response and request Body to unread state (fixes #65)

This commit is contained in:
evilsocket 2018-02-22 13:40:04 +01:00
parent 2771821169
commit 9ba9cb8c52
2 changed files with 6 additions and 0 deletions

View file

@ -1,6 +1,7 @@
package modules package modules
import ( import (
"bytes"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -61,6 +62,8 @@ func (j *JSRequest) ReadBody() string {
} }
j.Body = string(raw) j.Body = string(raw)
// reset the request body to the original unread state
j.req.Body = ioutil.NopCloser(bytes.NewBuffer(raw))
return j.Body return j.Body
} }

View file

@ -1,6 +1,7 @@
package modules package modules
import ( import (
"bytes"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net/http" "net/http"
@ -99,6 +100,8 @@ func (j *JSResponse) ReadBody() string {
j.Body = string(raw) j.Body = string(raw)
j.bodyRead = true j.bodyRead = true
// reset the request body to the original unread state
j.resp.Body = ioutil.NopCloser(bytes.NewBuffer(raw))
return j.Body return j.Body
} }