misc: small fix or general refactoring i did not bother commenting

This commit is contained in:
evilsocket 2018-03-27 15:34:03 +02:00
parent ea31346e3e
commit d9dba33cce
No known key found for this signature in database
GPG key ID: 1564D7F30393A456

View file

@ -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))
}
}