-
Notifications
You must be signed in to change notification settings - Fork 16
Fix finding a request; optimization of saving requests. #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
Fix finding a request; optimization of saving requests.
Add method to get recorded request
| recordedRequests.find { recordedRequest -> | ||
| url.contains(recordedRequest.url) | ||
| url == recordedRequest.url && method == recordedRequest.method | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason why contains was used instead of == when checking the URL match is that sometimes it fails to record the whole URL, and we want to be able to find it based on a partial match. So I suggest we keep the contains for the URL.
| override fun equals(other: Any?): Boolean { | ||
| if (other !is RecordedRequest) return super.equals(other) | ||
| return url == other.url | ||
| && method == other.method | ||
| && body == other.body | ||
| && headers == other.headers | ||
| && formParameters == other.formParameters | ||
| } | ||
|
|
||
| override fun hashCode(): Int { | ||
| return super.hashCode() | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think these are needed, Kotlin generates equals and hashCode for data classes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I presume the idea is to make the two requests equal only when a subset of parameters are equal, but for example not necessarily "trace" or "enctype".
| private fun addRecordedRequest(recordedRequest: RecordedRequest) { | ||
| synchronized(recordedRequests) { | ||
| recordedRequests.add(recordedRequest) | ||
| if (!recordedRequests.equals(recordedRequest)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the goal here? Why is it a problem if we record a request multiple times?
Fix finding a request; optimization of saving requests.