mockwebserver / okhttp3.mockwebserver / MockWebServer / takeRequest

takeRequest

fun takeRequest(): RecordedRequest

Awaits the next HTTP request, removes it, and returns it. Callers should use this to verify the request was sent as intended. This method will block until the request is available, possibly forever.

Return
the head of the request queue

fun takeRequest(timeout: Long, unit: TimeUnit): RecordedRequest

Awaits the next HTTP request (waiting up to the specified wait time if necessary), removes it, and returns it. Callers should use this to verify the request was sent as intended within the given time.

Parameters

timeout - how long to wait before giving up, in units of unit

unit - a TimeUnit determining how to interpret the timeout parameter

Return
the head of the request queue