Dispatcher

Handler for mock server requests.

Inheritors

Constructors

Link copied to clipboard
constructor()

Functions

Link copied to clipboard
abstract fun dispatch(request: RecordedRequest): MockResponse

Returns a response to satisfy request. This method may block (for instance, to wait on a CountdownLatch).

Link copied to clipboard
open fun peek(): MockResponse

Returns an early guess of the next response, used for policy on how an incoming request should be received. The default implementation returns an empty response. Mischievous implementations can return other values to test HTTP edge cases, such as unhappy socket policies or throttled request bodies.

Link copied to clipboard
open fun shutdown()

Release any resources held by this dispatcher. Any requests that are currently being dispatched should return immediately. Responses returned after shutdown will not be transmitted: their socket connections have already been closed.