1
0
mirror of https://github.com/MontFerret/ferret.git synced 2025-09-16 09:06:36 +02:00

refactor HTTPResponse.Compare

This commit is contained in:
Владимир Фетисов
2019-10-07 22:41:38 +03:00
parent 05eb9bc5f5
commit 08c6ddbbca

View File

@@ -30,20 +30,17 @@ func (resp *HTTPResponse) Compare(other core.Value) int64 {
return Compare(HTTPResponseType, other.Type()) return Compare(HTTPResponseType, other.Type())
} }
otherObj := values.Parse(other) otherResp := other.(*HTTPResponse)
respObj := values.Parse(resp)
// HTTPHeaders has it's own Compare comp := resp.Headers.Compare(otherResp.Headers)
respObj.(*values.Object).Set( if comp != 0 {
values.NewString("Headers"), return comp
resp.Headers, }
)
otherObj.(*values.Object).Set(
values.NewString("Headers"),
other.(*HTTPResponse).Headers,
)
return respObj.Compare(otherObj) // it makes no sense to compare Status strings
// because they are always equal if StatusCode's are equal
return values.NewInt(resp.StatusCode).
Compare(values.NewInt(resp.StatusCode))
} }
func (resp *HTTPResponse) Unwrap() interface{} { func (resp *HTTPResponse) Unwrap() interface{} {