RequestMatch

fun interface RequestMatch(source)

A predicate over an HttpRequest that selects the requests a FakeHttpTransport stub answers. It is a fun interface, so a consumer writes RequestMatch { it.url.host == "api.example.com" }; the companion holds the common shapes and and combines them.

Stable Core, source compatibility only. A frozen single-method predicate, not a seam: no opt-in is involved. Path and query text is compared, never validated. path compares Url.encodedPath exactly with the given (already percent-encoded) path, and matches query pairs after decoding them as OkHttp's HttpUrl does (+ is a space, %XX is a byte, a name without = has no value): an expected pair matches when some decoded pair equals it, order and extra pairs are ignored, and a null-valued pair never matches an expected pair. A matcher runs under the fake's lock and must not block.

Types

Link copied to clipboard
object Companion

The common matches.

Functions

Link copied to clipboard
open infix fun and(other: RequestMatch): RequestMatch

Combines two matches.

Link copied to clipboard
abstract fun matches(request: HttpRequest): Boolean

Decides whether a request is accepted.