Builder

Constructors

Link copied to clipboard
constructor()

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var code: Int
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val settings: Settings
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
Link copied to clipboard

Adds header as an HTTP header. For well-formed HTTP header should contain a name followed by a colon and a value.

Adds a new header with the name and value. This may be used to add multiple headers with the same name.

Link copied to clipboard

Adds a new header with the name and value. This may be used to add multiple headers with the same name. Unlike addHeader this does not validate the name and value.

Link copied to clipboard

Adds an HTTP 1xx response to precede this response. Note that this response's headers delay applies after this response is transmitted. Set a headers delay on that response to delay its transmission.

Link copied to clipboard

When protocols include HTTP_2, this attaches a pushed stream to this response.

Link copied to clipboard

Sets the response body to the UTF-8 encoded bytes of body.

Link copied to clipboard

Set the delayed time of the response body to delay. This applies to the response body only; response headers are not affected.

Link copied to clipboard
Link copied to clipboard
fun chunkedBody(body: String, maxChunkSize: Int = Int.MAX_VALUE): MockResponse.Builder

Sets the response body to the UTF-8 encoded bytes of body, chunked every maxChunkSize bytes.

fun chunkedBody(body: Buffer, maxChunkSize: Int = Int.MAX_VALUE): MockResponse.Builder

Sets the response body to body, chunked every maxChunkSize bytes.

Link copied to clipboard

Removes all HTTP headers including any "Content-Length" and "Transfer-encoding" headers that were added by default.

Link copied to clipboard
open override fun clone(): MockResponse.Builder
Link copied to clipboard
Link copied to clipboard

Process the response without even attempting to reading the request body. For HTTP/2 this will close the response stream after the response body or trailers. For HTTP/1 this will close the socket after the response body or trailers.

Link copied to clipboard

Don't trust the client during the SSL handshake.

Link copied to clipboard

Sets the headers and returns this.

Link copied to clipboard
Link copied to clipboard

Configures this response to be served as a response to an HTTP CONNECT request, either for doing HTTPS through an HTTP proxy, or HTTP/2 prior knowledge through an HTTP proxy.

Link copied to clipboard

Trigger socketEffect while reading the request body.

Link copied to clipboard

Trigger socketEffect before the request headers are read.

Link copied to clipboard

Trigger socketEffect while writing the response body.

Link copied to clipboard

Trigger socketEffect after writing the response body.

Link copied to clipboard

Trigger socketEffect before the response headers are sent.

Link copied to clipboard

Removes all headers named name.

Link copied to clipboard

Removes all headers named name, then adds a new header with the name and value.

Link copied to clipboard
fun settings(settings: Settings): MockResponse.Builder

When protocols include HTTP_2, this pushes settings before writing the response.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Sets the status and returns this.

Link copied to clipboard
fun throttleBody(bytesPerPeriod: Long, period: Long, unit: TimeUnit): MockResponse.Builder

Throttles the request reader and response writer to sleep for the given period after each series of bytesPerPeriod bytes are transferred. Use this to simulate network behavior.

Link copied to clipboard

Sets the trailers and returns this.

Link copied to clipboard
Link copied to clipboard

Attempts to perform a web socket upgrade on the connection. This will overwrite any previously set status, body, or streamHandler.