pub struct ConnCtrl { /* private fields */ }Expand description
Controls the lifetime of the transport connection serving a request.
A control is shared by every request multiplexed over the same connection. Shutting down an HTTP/2 or HTTP/3 connection therefore also affects its other in-flight request streams.
Implementations§
Source§impl ConnCtrl
impl ConnCtrl
Sourcepub fn graceful_shutdown(&self)
pub fn graceful_shutdown(&self)
Stops accepting new requests and lets accepted requests finish.
A later call to abort escalates graceful shutdown to an
immediate abort.
Sourcepub fn abort(&self)
pub fn abort(&self)
Immediately aborts the underlying transport connection.
The server will abruptly close the connection without sending any response.
This causes clients to encounter errors such as curl: (52) Empty reply from server.
Aborting the connection immediately frees up system resources allocated to the request flow. This forceful teardown should only be used in critical scenarios, such as mitigating active attacks, where maintaining the connection poses a security risk.
Sourcepub fn is_graceful_shutdown(&self) -> bool
pub fn is_graceful_shutdown(&self) -> bool
Returns true after graceful shutdown has been requested.
Sourcepub fn is_aborted(&self) -> bool
pub fn is_aborted(&self) -> bool
Returns true after immediate abort has been requested.
Sourcepub fn relax_timeouts(&self)
pub fn relax_timeouts(&self)
Suspends the transport idle and write-stall fuse timeouts for this connection.
The fuse connection_idle_timeout
and write_stall_timeout exist to
close connections that stall mid-request. Long-lived protocols built on top of an HTTP
upgrade — WebSocket, or a hand-rolled tunnel — legitimately spend long stretches with no
transport activity and would otherwise trip those timers. A handler that hands the
connection off to such a protocol should call this to keep the transport open.
This does not affect graceful_shutdown or
abort; an aborted connection is still torn down.
Sourcepub fn is_relaxed(&self) -> bool
pub fn is_relaxed(&self) -> bool
Returns true once relax_timeouts has been called.