Skip to main content

HttpConfig

Struct HttpConfig 

Source
pub struct HttpConfig {
Show 25 fields pub expected_statuses: Vec<ExpectedStatus>, pub max_idle_connections: usize, pub keep_alive: Option<String>, pub idle_connection_timeout: Option<String>, pub request_timeout: Option<String>, pub http2: bool, pub http2_connections: usize, pub user_agent: String, pub decompress: bool, pub discard_response_bodies: bool, pub max_redirects: u32, pub no_redirects: bool, pub histogram_max_ms: Option<u64>, pub dns_ttl: Option<String>, pub dns_select: Option<String>, pub dns_policy: Option<String>, pub no_connection_reuse: bool, pub no_vu_connection_reuse: bool, pub rps: Option<f64>, pub hosts: HashMap<String, String>, pub blacklist_ips: Vec<String>, pub max_response_bytes: Option<u64>, pub proxy: ProxyConfig, pub http_debug: bool, pub http_debug_full: bool,
}
Expand description

HTTP client configuration.

Fields§

§expected_statuses: Vec<ExpectedStatus>

Expected response status codes/ranges that determine request success. Used to drive the http_req_failed Rate metric. Default: ["200-399"] — 2xx and 3xx are success, everything else fails.

§max_idle_connections: usize

Connection pool max idle connections.

§keep_alive: Option<String>

Keep-alive duration.

§idle_connection_timeout: Option<String>

Timeout for idle connections.

§request_timeout: Option<String>

Global per-request timeout (k6 timeout), e.g. "30s". Applied as the client-level ceiling for every request; a per-request timeout overrides it with a shorter value. None (default) uses the engine default of 10 seconds. Bounds how long a hung server can stall a VU (which in turn bounds the engine’s VU-drain loop).

§http2: bool

Whether to enable HTTP/2.

§http2_connections: usize

Number of HTTP/2 connection lanes (default 1). Each lane is an independent reqwest::Client with its own connection pool. VUs are assigned to lanes round-robin by vu_id % N. Spreading load across N h2 connections hides per-connection server limits and parallelizes the single-core frame demux. k6 cannot do this at all.

§user_agent: String

User-agent header value.

§decompress: bool

Whether to decompress response bodies.

§discard_response_bodies: bool

Whether to discard response bodies entirely (don’t store bytes). Saves memory and bandwidth at the cost of not being able to inspect response content in scripts.

§max_redirects: u32

Max redirects to follow.

§no_redirects: bool

Disable redirect following entirely (--no-redirects). When true the 3xx response is returned as-is and no redirect hops are captured. k6 always follows redirects; this flag lets Tropel opt out.

§histogram_max_ms: Option<u64>

Optional fixed ceiling for the latency histogram, in MILLISECONDS. None (default) uses hdrhistogram auto-resize — no ceiling, so very slow requests are recorded exactly instead of being clipped at 60 s. Set this to bound memory for runs with pathological outliers.

§dns_ttl: Option<String>

DNS cache TTL (k6 dns.ttl), e.g. "5m", "inf". None (default) disables caching — every request resolves. "0" also disables it.

§dns_select: Option<String>

DNS address selection policy (k6 dns.select): "first", "roundRobin", "random". None (default) keeps all resolved addresses in lookup order (reqwest’s default behavior).

§dns_policy: Option<String>

DNS address policy (k6 dns.policy): "preferIPv4", "preferIPv6", "onlyIPv4", "onlyIPv6", "any". None (default) keeps the resolved address family order unchanged.

§no_connection_reuse: bool

Close the connection after every request (k6 noConnectionReuse). Disables connection pooling entirely — each request opens a fresh connection, which trades latency for isolation.

§no_vu_connection_reuse: bool

k6 noVUConnectionReuse parity. When true, forces a fresh client (own connection pool) per VU. Default false: every VU shares one pooled client via Arc clone, keeping connections warm and TLS sessions reusable.

§rps: Option<f64>

Global request-rate cap in requests/second (k6 rps). When set, the whole run is paced so no more than this many requests start per second, shared across all VUs. None (default) is unlimited.

§hosts: HashMap<String, String>

Static hostname → IP mapping (k6 hosts), e.g. {"api.example.com": "127.0.0.1"}. Lookups for these hosts are served from the map without hitting DNS. Values may be comma-separated to provide several addresses; keys may be wildcards ("*.example.com").

§blacklist_ips: Vec<String>

IP addresses / CIDRs that requests may never connect to (k6 blacklistIPs), e.g. ["10.0.0.0/8", "192.168.1.5"]. When every resolved address is blacklisted the request fails with a clear error.

§max_response_bytes: Option<u64>

Hard ceiling on the response body size in BYTES, enforced while the body is streamed (final response AND redirect-hop bodies). None (default) is unlimited — k6 semantics. Proxy-style consumers (KnockPort relay) set this so a runaway upstream can’t fill memory.

§proxy: ProxyConfig

Log every HTTP request/response at debug level (method, URL, status, timing). Off by default; enable with the --http-debug CLI flag. k6’s --http-debug=full also prints request/response bodies — that extra mode is http_debug_full. Proxy configuration (ask 17). ProxyMode::Off by default, so every existing config behaves exactly as before. The container’s own #[serde(default)] covers an absent key.

§http_debug: bool§http_debug_full: bool

--http-debug=full (k6 parity): also print the request/response bodies, not just the head lines. Only meaningful with http_debug.

Trait Implementations§

Source§

impl Clone for HttpConfig

Source§

fn clone(&self) -> HttpConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HttpConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for HttpConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for HttpConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for HttpConfig

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more