30#ifndef A11_NET_WEBSOCKET_WIRE_STREAM_H_
31#define A11_NET_WEBSOCKET_WIRE_STREAM_H_
39#include <absl/base/nullability.h>
40#include <absl/status/status.h>
41#include <absl/status/statusor.h>
88 struct ConstructorToken {};
101 static absl::StatusOr<std::shared_ptr<WebSocketWireStream>>
CreateClient(
114 return request_path_;
124 return request_headers_;
131 static absl::StatusOr<std::shared_ptr<WebSocketWireStream>> CreateAccepted(
132 HttpRequest request, std::shared_ptr<Http2ResponseWriter> response,
137 std::string request_path_;
189 std::function<
a11::Task(std::shared_ptr<WebSocketWireStream>)>;
199 :
public std::enable_shared_from_this<WebSocketWireServer> {
208 static absl::StatusOr<std::shared_ptr<WebSocketWireServer>>
Create(
215 absl::StatusOr<std::uint16_t>
port()
const;
217 [[nodiscard]]
bool running()
const;
219 [[nodiscard]]
void* absl_nullable
GetImpl()
const;
225 : state_(std::move(state)) {}
227 std::shared_ptr<State> state_;
Shared WireStream lifecycle and framing for binary channels.
Definition channel_wire_stream.h:69
Accepts inbound WebSocket connections and hands each to a callback.
Definition websocket_wire_stream.h:199
bool running() const
Definition websocket_wire_stream.cc:287
absl::StatusOr< std::uint16_t > port() const
Definition websocket_wire_stream.cc:279
~WebSocketWireServer()
Definition websocket_wire_stream.cc:266
absl::Status Stop()
Stops the server and closes the listening socket.
Definition websocket_wire_stream.cc:270
void *absl_nullable GetImpl() const
Definition websocket_wire_stream.cc:292
static absl::StatusOr< std::shared_ptr< WebSocketWireServer > > Create(OnWebSocketStream on_stream, WebSocketServerOptions options={})
Starts a WebSocket server accepting A11 connections.
Definition websocket_wire_stream.cc:185
A WireStream that carries A11 traffic over a client or accepted WebSocket.
Definition websocket_wire_stream.h:86
WebSocketWireStream(ConstructorToken, std::shared_ptr< State > state)
Definition websocket_wire_stream.h:127
const HttpHeaders & GetRequestHeaders() const
The headers the accepted request carried.
Definition websocket_wire_stream.h:123
const std::string & GetRequestPath() const
The path this stream was accepted on, query string included.
Definition websocket_wire_stream.h:113
static absl::StatusOr< std::shared_ptr< WebSocketWireStream > > CreateClient(std::string_view url, WireStreamOptions options={}, WebSocketClientOptions websocket_options={})
Dials a WebSocket endpoint and returns a WireStream over it.
Definition websocket_wire_stream.cc:96
GET /actions, on whichever server happens to hold the port.
Completion values used by every asynchronous A11 operation.
A11's nghttp2 HTTP/2 client, server, and streaming primitives.
std::function< a11::Task(std::shared_ptr< WebSocketWireStream >)> OnWebSocketStream
Callback invoked with a fresh WireStream for each accepted connection.
Definition websocket_wire_stream.h:189
std::vector< std::pair< std::string, std::string > > HttpHeaders
An ordered list of (name, value) HTTP/2 header fields.
Definition http2.h:70
Future< Unit > Task
Asynchronous operation whose only successful result is completion itself.
Definition future.h:431
stores::ChunkStoreReaderOptions options
Definition runtime_streams.cc:31
Packetisation and incomplete-message bounds for a binary WireStream.
Definition channel_wire_stream.h:46
Where and whether a server answers discovery over plain HTTP.
Definition describe_endpoint.h:72
Body-size limits, buffering thresholds, deadline, TLS, and HTTP protocol negotiation for an HTTP clie...
Definition http2.h:150
A parsed HTTP/2 request: pseudo-headers, fields, and body.
Definition http2.h:90
Client-side tuning for a WebSocketWireStream connection.
Definition websocket_wire_stream.h:59
absl::Time handshake_deadline
How long the handshake alone may take.
Definition websocket_wire_stream.h:72
HttpHeaders headers
Extra WebSocket handshake headers.
Definition websocket_wire_stream.h:61
absl::Status Validate() const
Definition websocket_wire_stream.cc:89
ChannelFramingOptions framing
Packet splitting and reassembly bounds.
Definition websocket_wire_stream.h:62
Http2Options http2_options
HTTP/2 connection and TLS policy.
Definition websocket_wire_stream.h:60
Listen address, path, and per-stream defaults for a WebSocketWireServer.
Definition websocket_wire_stream.h:151
std::string path_prefix
Also accept anything under this prefix, as well as path.
Definition websocket_wire_stream.h:161
ServerHeaderOptions headers
Response-header policy for this port's HTTP surface – the Server header, cross-origin access and cach...
Definition websocket_wire_stream.h:181
std::uint16_t port
Listen port; zero requests an ephemeral port.
Definition websocket_wire_stream.h:163
std::string bind_address
Local listen address.
Definition websocket_wire_stream.h:162
ChannelFramingOptions framing
Framing for accepted streams.
Definition websocket_wire_stream.h:165
Http2Options http2_options
Server HTTP/2 and TLS policy.
Definition websocket_wire_stream.h:166
std::string path
Exact WebSocket endpoint path.
Definition websocket_wire_stream.h:152
DescribeEndpointOptions describe
GET /actions on this same port, when something above filled in the handler.
Definition websocket_wire_stream.h:173
WireStreamOptions stream_options
Defaults for accepted streams.
Definition websocket_wire_stream.h:164
absl::Status Validate() const
Definition websocket_wire_stream.cc:154
Definition websocket_wire_stream.cc:173
Buffering, sizing, and deadline limits for a WireStream endpoint.
Definition wire_stream.h:58
A11's transport abstraction: the bidirectional WireStream channel and the options/callbacks that driv...