Correcting content-length for stripped response body

This commit is contained in:
mo 2020-02-13 18:08:44 -06:00
commit 58b31d351f

View file

@ -8,6 +8,7 @@ import (
"net/url"
"regexp"
"strings"
"strconv"
"github.com/bettercap/bettercap/log"
"github.com/bettercap/bettercap/packets"
@ -377,6 +378,8 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) {
s.hosts.Track(hostOriginal, hostStripped)
}
res.Header.Set("Content-Length", strconv.Itoa(len(body)))
// reset the response body to the original unread state
// but with just a string reader, this way further calls
// to ioutil.ReadAll(res.Body) will just return the content