mirror of
https://github.com/bettercap/bettercap
synced 2025-07-16 10:03:39 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
ea31346e3e
commit
d9dba33cce
1 changed files with 41 additions and 37 deletions
|
@ -319,8 +319,6 @@ func (s *SSLStripper) isMaxRedirs(hostname string) bool {
|
|||
func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) {
|
||||
if s.enabled == false {
|
||||
return
|
||||
} else if s.isContentStrippable(res) == false {
|
||||
return
|
||||
}
|
||||
|
||||
// is the server redirecting us?
|
||||
|
@ -355,7 +353,9 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) {
|
|||
// process response headers
|
||||
s.stripResponseHeaders(res)
|
||||
|
||||
// fetch the HTML body
|
||||
// if we have a text or html content type, fetch the body
|
||||
// and perform sslstripping
|
||||
if s.isContentStrippable(res) == true {
|
||||
raw, err := ioutil.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
log.Error("Could not read response body: %s", err)
|
||||
|
@ -393,5 +393,9 @@ func (s *SSLStripper) Process(res *http.Response, ctx *goproxy.ProxyCtx) {
|
|||
}
|
||||
|
||||
// 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
|
||||
// we stripped without downloading anything again.
|
||||
res.Body = ioutil.NopCloser(strings.NewReader(body))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue