mirror of
https://github.com/bettercap/bettercap
synced 2025-08-20 13:33:21 -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
|
Headers string
|
||||||
Body string
|
Body string
|
||||||
|
|
||||||
refHash string
|
refHash string
|
||||||
resp *http.Response
|
resp *http.Response
|
||||||
|
bodyRead bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewJSResponse(res *http.Response) *JSResponse {
|
func NewJSResponse(res *http.Response) *JSResponse {
|
||||||
|
@ -43,6 +44,7 @@ func NewJSResponse(res *http.Response) *JSResponse {
|
||||||
ContentType: cType,
|
ContentType: cType,
|
||||||
Headers: headers,
|
Headers: headers,
|
||||||
resp: res,
|
resp: res,
|
||||||
|
bodyRead: false,
|
||||||
}
|
}
|
||||||
resp.UpdateHash()
|
resp.UpdateHash()
|
||||||
|
|
||||||
|
@ -50,7 +52,7 @@ func NewJSResponse(res *http.Response) *JSResponse {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *JSResponse) NewHash() string {
|
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() {
|
func (j *JSResponse) UpdateHash() {
|
||||||
|
@ -58,6 +60,11 @@ func (j *JSResponse) UpdateHash() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (j *JSResponse) WasModified() bool {
|
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()
|
newHash := j.NewHash()
|
||||||
if newHash != j.refHash {
|
if newHash != j.refHash {
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue