Update http_proxy_js_response.go

This commit is contained in:
buffermet 2025-02-13 21:32:26 +01:00 committed by GitHub
commit 25c6339275
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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++ {