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.
- Client
Response - A response fetched by
getorClient::get, fully read. - Connection
- A blocking server connection:
ServerConndriven over aTcpStream. - 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.
- Server
Config - Settings for
Server. - Shutdown
Handle - Stops a running
Server::servefrom another thread. - Upgraded
- A connection handed over by a
101 Switching Protocols(or a 2xx toCONNECT): 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
urlwithGETusing the defaultClient. - now_
date - The current time as a
Datevalue, from a per-threadDateCache: the system clock is read on every call, the value is reformatted only when the second changes.Connection::respondandServerwrite it on every response that did not set its owndate. - post
- Sends
bodytourlwithPOSTandcontent-type: content_type, using the defaultClient. - serve
- Binds
addrand serveshandlerwith the defaultServerConfiguntil the process ends: the shortest way to run a server. UseServerfor a shutdown handle, settings, or an upgrade hook.