Skip to main content

Crate h11

Crate h11 

Source
Expand description

Sans-I/O HTTP/1.1 protocol handling.

This crate parses and serializes HTTP/1.1 events without owning sockets, timers, or tasks. Applications feed bytes into a Connection with Connection::receive_data, pull protocol events with Connection::next_event, and serialize outbound events with Connection::send.

The API follows the same model as Python h11: callers drive a state machine by exchanging typed events such as Request, Response, Data, and EndOfMessage. Invalid local usage returns LocalProtocolError, while malformed peer input returns RemoteProtocolError.

Use the fallible constructors such as Request::new_http11, Response::new_final_http11, and Headers::new for public inputs. Struct fields are currently public for compatibility, but manually-built values should be validated before being sent.

Structs§

Connection
Sans-I/O HTTP/1.1 connection state machine.
ConnectionClosed
Notification that the connection has closed.
Data
HTTP message body data.
EndOfMessage
End of the current HTTP message.
Headers
HTTP header collection.
LocalProtocolError
Error caused by invalid local API usage or invalid locally-created events.
RemoteProtocolError
Error caused by malformed peer input.
Request
HTTP request head event.
Response
HTTP response head event.

Enums§

Event
Protocol events emitted and accepted by crate::Connection.
EventType
Internal event classification used by the state machine.
ProtocolError
Protocol error wrapper used by fallible public APIs.
Role
Endpoint role for a connection.
State
Per-role state in the HTTP/1.1 connection state machine.
Switch
Protocol switch proposals and acceptances.

Constants§

PRODUCT_ID
Product token for identifying this protocol implementation.