Skip to content

Conversation

@kumold
Copy link
Contributor

@kumold kumold commented Oct 17, 2023

Fix finding a request; optimization of saving requests.

Fix finding a request; optimization of saving requests.
Add method to get recorded request
Comment on lines 23 to 25
recordedRequests.find { recordedRequest ->
url.contains(recordedRequest.url)
url == recordedRequest.url && method == recordedRequest.method
}
Copy link
Owner

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.

Comment on lines +39 to +50
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()
}
Copy link
Owner

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.

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))
Copy link
Owner

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants