mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 05:23:19 -07:00
misc: small fix or general refactoring i did not bother commenting
This commit is contained in:
parent
10425a0dc7
commit
4d49de674b
1 changed files with 10 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue