HttpTransport class
A Transport built on shelf + shelf_web_socket.
Serves plaintext HTTP (http/ws) or, with a TlsProvider, TLS
(https/wss). WebSocket upgrades are handled on the same listener as
ordinary requests, so a single port carries both request/response services
and WebSocket services.
Constructors
- HttpTransport.http({Object address = '0.0.0.0', required int port})
-
A plaintext HTTP/WS transport bound to
address:port. Passport: 0for an ephemeral port.factory - HttpTransport.https({Object address = '0.0.0.0', required int port, required TlsProvider tls})
-
A TLS HTTPS/WSS transport bound to
address:port, usingtlsfor certificate material.factory
Properties
- address → Object
-
The bound address (host or IP).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isBound → bool
-
Whether the transport is currently bound and listening.
no setter
- isSecure → bool
-
Whether this transport terminates TLS.
no setter
- port → int
-
The port the listener is bound to. Valid only after bind; when bound
with port
0this reflects the ephemeral port actually chosen.no setter - protocol → TransportProtocol
-
The base protocol served (
httporhttps). Individual requests may be reported asws/wsswhen they are WebSocket upgrades.no setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tls → TlsProvider?
-
The TLS material provider, or
nullfor a plaintext listener.final
Methods
-
bind(
{required HubRequestHandler onRequest, ConnectionHandler? onUpgrade}) → Future< void> - Binds and starts listening.
-
close(
{bool force = false}) → Future< void> -
Stops the listener. With
force, open connections are dropped immediately. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
rebind(
) → Future< void> -
Rebinds the listener with a freshly built SecurityContext (used when a
certificate is renewed) without dropping live connections: a fresh
sharedlistener is bound on the same port with the new certificate, then the old listener is drained gracefully (force: false) so in-flight connections finish on the old certificate while new ones use the renewed one. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited