pub struct HttpsServer { /* private fields */ }server only.Expand description
An HTTPS Trust Tasks server.
Build with HttpsServer::builder, register handlers via
HttpsServerBuilder::on / HttpsServerBuilder::on_async, then
Self::serve.
Implementations§
Source§impl HttpsServer
impl HttpsServer
Sourcepub fn builder() -> HttpsServerBuilder
pub fn builder() -> HttpsServerBuilder
Start a new builder.
Sourcepub fn body_limit(&self) -> usize
pub fn body_limit(&self) -> usize
The request-body limit Self::into_router applies: MAX_BODY_BYTES,
or the largest maxDocumentBytes a registered request type declares if
that is larger, or what HttpsServerBuilder::max_body_bytes set.
Sourcepub fn into_router(self) -> Router
pub fn into_router(self) -> Router
Build the axum Router without starting a listener — useful for
integration tests that want to spawn the app inline.
The router applies an explicit DefaultBodyLimit of
Self::body_limit as an audited DoS control (SPEC §12.2): the body is
buffered and parsed before authentication, so an unbounded body would
otherwise be a pre-auth memory-exhaustion vector. JSON nesting depth is
separately bounded by serde_json’s default 128-level recursion limit,
so a pathologically nested body within the size budget fails to parse
(→ malformedRequest) rather than overflowing the stack. Once the type
is known, the document is held to its own specification’s bound.
It also applies two liveness controls, both configurable on the
builder (HttpsServerBuilder::request_timeout,
HttpsServerBuilder::max_concurrent_requests):
- a
TimeoutLayer— a request that outlives its budget is abandoned with408 Request Timeoutrather than holding a connection and a task open indefinitely (slowloris). It fires at anawait, so it bounds async handlers and not synchronous ones — see the module docs, Handlers and blocking; - a
ConcurrencyLimitLayer— requests past the ceiling wait for a permit instead of each pinning a parse buffer, bounding the memory a flood can commit.
Both sit outside the body limit, so they also bound the time and concurrency spent reading a body that is still under the size cap.
Sourcepub async fn serve(self, addr: impl ToSocketAddrs) -> Result<()>
pub async fn serve(self, addr: impl ToSocketAddrs) -> Result<()>
Bind to addr and serve incoming requests. Returns when the
listener stops.
The router returned by Self::into_router carries the body-size,
timeout and concurrency controls; this method adds nothing beyond
binding the listener, so a caller that builds its own listener gets
the same protections.