From 4d49de674b199446b0e31cdc75bf2e7291f03eda Mon Sep 17 00:00:00 2001 From: evilsocket Date: Sun, 11 Feb 2018 20:49:20 +0100 Subject: [PATCH] misc: small fix or general refactoring i did not bother commenting --- modules/http_proxy_js_response.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/modules/http_proxy_js_response.go b/modules/http_proxy_js_response.go index ef93d60c..74915a51 100644 --- a/modules/http_proxy_js_response.go +++ b/modules/http_proxy_js_response.go @@ -17,8 +17,9 @@ type JSResponse struct { Headers string Body string - refHash string - resp *http.Response + refHash string + resp *http.Response + bodyRead bool } func NewJSResponse(res *http.Response) *JSResponse { @@ -43,6 +44,7 @@ func NewJSResponse(res *http.Response) *JSResponse { ContentType: cType, Headers: headers, resp: res, + bodyRead: false, } resp.UpdateHash() @@ -50,7 +52,7 @@ func NewJSResponse(res *http.Response) *JSResponse { } func (j *JSResponse) NewHash() string { - return fmt.Sprintf("%d.%s.%s.%s", j.Status, j.ContentType, j.Headers, j.Body) + return fmt.Sprintf("%d.%s.%s", j.Status, j.ContentType, j.Headers) } func (j *JSResponse) UpdateHash() { @@ -58,6 +60,11 @@ func (j *JSResponse) UpdateHash() { } func (j *JSResponse) WasModified() bool { + // body was read + if j.bodyRead == true { + return true + } + // check if any of the fields has been changed newHash := j.NewHash() if newHash != j.refHash { return true