pub struct MockOptions {
pub port: Option<u16>,
pub max_header_bytes: Option<usize>,
pub max_body_bytes: Option<usize>,
pub reject_transfer_encoding: bool,
pub max_connections: Option<usize>,
pub linger: Option<Duration>,
pub on_request: Option<Arc<dyn Fn(&RequestLog) + Send + Sync>>,
}Expand description
Extra behaviour for MockServer::start_opts. MockOptions::default() behaves exactly
like MockServer::start_with: ephemeral port, no limits, no cap, no linger.
Fields§
§port: Option<u16>Bind this port on 127.0.0.1 instead of an ephemeral one (serve --port n).
max_header_bytes: Option<usize>Request head larger than this gets 431.
max_body_bytes: Option<usize>A Content-Length larger than this gets 413.
reject_transfer_encoding: boolAny Transfer-Encoding request header gets 501 (only Content-Length bodies are read).
max_connections: Option<usize>At most this many connections are served at once; extra ones get 503 and are closed.
linger: Option<Duration>After a reply, shut down the write side, then read and discard the peer’s remaining bytes for up to this long before closing, so a close with unread input cannot reset the connection and discard a reply the client has not read.
on_request: Option<Arc<dyn Fn(&RequestLog) + Send + Sync>>Called once per request, after it is answered (or dropped, or rejected).