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. Pass port: 0 for 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, using tls for 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 0 this reflects the ephemeral port actually chosen.
no setter
protocol → TransportProtocol
The base protocol served (http or https). Individual requests may be reported as ws/wss when 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 null for 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 shared listener 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