Merge pull request #700 from alnaeemi/master

Correcting content-length for stripped response body
This commit is contained in:
Simone Margaritelli 2020-02-20 09:11:57 +01:00 committed by GitHub
commit 8ae28f4b3d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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