From 25c6339275d37ef6c7832bc8bbc9cdd7b1689cfd Mon Sep 17 00:00:00 2001 From: buffermet <29265684+buffermet@users.noreply.github.com> Date: Thu, 13 Feb 2025 21:32:26 +0100 Subject: [PATCH] Update http_proxy_js_response.go --- modules/http_proxy/http_proxy_js_response.go | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/modules/http_proxy/http_proxy_js_response.go b/modules/http_proxy/http_proxy_js_response.go index 051812ef..c66cbe7f 100644 --- a/modules/http_proxy/http_proxy_js_response.go +++ b/modules/http_proxy/http_proxy_js_response.go @@ -76,6 +76,28 @@ func (j *JSResponse) WasModified() bool { return j.NewHash() != j.refHash } +func (j *JSResponse) CheckIfModifiedAndUpdateHash() bool { + newHash := j.NewHash() + // body was read + if j.bodyRead { + // body was read + j.refHash = newHash + return true + } else if j.bodyClear { + // body was cleared manually + j.refHash = newHash + return true + } else if j.Body != "" { + // body was not read but just set + j.refHash = newHash + return true + } + // check if res was changed and update its hash + wasModified := j.refHash != newHash + j.refHash = newHash + return wasModified +} + func (j *JSResponse) GetHeader(name, deflt string) string { headers := strings.Split(j.Headers, "\r\n") for i := 0; i < len(headers); i++ {