Skip to main content

Module blocking

Module blocking 

Source
Available on crate feature std only.
Expand description

A small blocking adapter over std::net: the Tier-1 path.

Server serves a handler on a socket with one thread per connection (bounded by ServerConfig::with_max_connections); Connection is the per-connection loop for callers who run their own accept loop or need the socket back after an upgrade; get fetches a URL. Everything here is a thin shell around ServerConn and ClientConn: all parsing, framing, and limit enforcement happens in the sans-IO core.

Only plain http:// is spoken; there is no TLS in this crate.

Structs§

Client
A blocking HTTP/1.1 client: one connection per request.
ClientResponse
A response fetched by get or Client::get, fully read.
Connection
A blocking server connection: ServerConn driven over a TcpStream.
Incoming
One request read by Connection::next_request: its head and its complete body.
Server
A blocking HTTP/1.1 server: one thread per connection, bounded.
ServerConfig
Settings for Server.
ShutdownHandle
Stops a running Server::serve from another thread.
Upgraded
A connection handed over by a 101 Switching Protocols (or a 2xx to CONNECT): the socket, the bytes of the new protocol that already arrived, and the target of the request that asked for the switch.

Enums§

Error
What can go wrong in the blocking adapter.

Functions§

get
Fetches url with GET using the default Client.
now_date
The current time as a Date value, from a per-thread DateCache: the system clock is read on every call, the value is reformatted only when the second changes. Connection::respond and Server write it on every response that did not set its own date.
post
Sends body to url with POST and content-type: content_type, using the default Client.
serve
Binds addr and serves handler with the default ServerConfig until the process ends: the shortest way to run a server. Use Server for a shutdown handle, settings, or an upgrade hook.