A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::net Namespace Reference

Namespaces

namespace  internal
 

Classes

struct  ByteChunkingOptions
 Bounds packet size and incomplete-message memory during reassembly. More...
 
struct  BytePacket
 Parsed packet metadata plus the owned piece of application payload. More...
 
class  ByteReassembler
 Bounded, thread-safe reassembly for interleaved binary messages. More...
 
struct  ChannelFramingOptions
 Packetisation and incomplete-message bounds for a binary WireStream. More...
 
class  ChannelWireStream
 Shared WireStream lifecycle and framing for binary channels. More...
 
struct  CorsOptions
 Cross-origin policy for an A11 HTTP surface. More...
 
struct  DescribeEndpointOptions
 Where and whether a server answers discovery over plain HTTP. More...
 
struct  DownloadOptions
 Where a download goes, and what proves it arrived intact. More...
 
struct  FetchOptions
 What to request, and how hard to try. More...
 
class  Http2Client
 An HTTP/2 client connection, reusable across many streams. More...
 
class  Http2Connection
 
class  Http2DuplexStream
 Client side of an HTTP/2 extended CONNECT stream. More...
 
struct  Http2Options
 Body-size limits, buffering thresholds, deadline, TLS, and HTTP protocol negotiation for an HTTP client or server. More...
 
class  Http2RequestBodyStream
 Pull-oriented request DATA for a request that stays open. More...
 
class  Http2ResponseStream
 A pull-oriented HTTP/2 response body stream. More...
 
class  Http2ResponseWriter
 Server-side handle for writing an HTTP/2 response to one request. More...
 
class  Http2Server
 An HTTP/2 server that dispatches each request to an async handler. More...
 
struct  Http2TlsOptions
 TLS settings for an HTTP/2 client or server (certificates, peer verification). More...
 
class  HttpConnectionLease
 A borrowed connection, held for as long as a caller needs it. More...
 
class  HttpConnectionPool
 Hands out connections to origins, sharing them while they are in use. More...
 
struct  HttpPushedResponse
 A response the server sent without being asked (HTTP/2 server push). More...
 
struct  HttpRequest
 A parsed HTTP/2 request: pseudo-headers, fields, and body. More...
 
struct  HttpResponse
 A fully buffered HTTP/2 response: head plus complete body. More...
 
struct  HttpResponseHead
 Status line and headers of an HTTP/2 response, without the body. More...
 
class  HttpSseClientWireStream
 The client-side HTTP SSE wire stream, dialing out to a server URL. More...
 
struct  HttpSseOptions
 Endpoint paths and transport tuning for an HTTP SSE wire stream. More...
 
class  HttpSseServer
 Hosts HTTP SSE wire streams on top of an HTTP/2 server. More...
 
class  HttpSseServerWireStream
 The server-side HTTP SSE wire stream, accepted from a client. More...
 
class  HttpSseWireStream
 Common base for the client and server HTTP SSE wire streams. More...
 
class  InProcessWireStream
 A WireStream endpoint wired directly to a peer in the same process. More...
 
struct  ParsedUrl
 An absolute URL split into the parts a connection needs. More...
 
struct  ServerHeaderOptions
 The response-header policy of one A11 HTTP surface. More...
 
struct  SignallingAdmission
 What a peer presented when asking to register an identity. More...
 
class  SignallingEndpoint
 An identity-bound endpoint into an in-process SignallingService. More...
 
struct  SignallingMessage
 One signalling payload: an SDP description, an ICE candidate, or an error. More...
 
class  SignallingService
 An in-process broker that routes signalling messages by identity. More...
 
class  SignallingTransport
 Abstract identity-bound channel over which signalling flows. More...
 
struct  TurnServer
 Address and credentials for a TURN relay used during ICE. More...
 
struct  WebRtcConfiguration
 ICE, fragmentation, and binding settings for a WebRTC connection. More...
 
class  WebRtcWireServer
 Accepts incoming WebRTC peer connections under a fixed identity. More...
 
class  WebRtcWireStream
 A WireStream that carries A11 traffic over a WebRTC data channel. More...
 
struct  WebSocketClientOptions
 Client-side tuning for a WebSocketWireStream connection. More...
 
struct  WebSocketServerOptions
 Listen address, path, and per-stream defaults for a WebSocketWireServer. More...
 
class  WebSocketSignallingClient
 A SignallingTransport that relays messages over a WebSocket. More...
 
struct  WebSocketSignallingClientOptions
 Connection tuning for a WebSocketSignallingClient. More...
 
class  WebSocketSignallingServer
 Fronts an in-process SignallingService over a WebSocket. More...
 
struct  WebSocketSignallingServerOptions
 Listen address, limits and policy hooks for a WebSocketSignallingServer. More...
 
class  WebSocketWireServer
 Accepts inbound WebSocket connections and hands each to a callback. More...
 
class  WebSocketWireStream
 A WireStream that carries A11 traffic over a client or accepted WebSocket. More...
 
class  WireStream
 A bidirectional, message-oriented channel between two A11 endpoints. More...
 
struct  WireStreamOptions
 Buffering, sizing, and deadline limits for a WireStream endpoint. More...
 
class  WireStreamWithRecv
 Pull-oriented adapter for a callback-driven WireStream. More...
 

Typedefs

using DescribeActionsHandler = std::function< absl::StatusOr< std::string >(std::string_view name, std::string_view query)>
 Answers a discovery request without opening a wire stream.
 
using OnFetchProgress = std::function< void(std::uint64_t bytes_done, std::uint64_t bytes_total)>
 Called as a body arrives.
 
using FetchSink = std::function< absl::Status(std::string_view chunk)>
 Receives body chunks in order.
 
using HttpHeaders = std::vector< std::pair< std::string, std::string > >
 An ordered list of (name, value) HTTP/2 header fields.
 
using Http2RequestHandler = std::function< a11::Task(HttpRequest request, std::shared_ptr< Http2ResponseWriter > response)>
 Callback dispatched for each inbound request, given a response writer.
 
using OnHttpSseConnect = std::function< a11::Task(std::shared_ptr< HttpSseServerWireStream >)>
 Callback invoked with each accepted server-side SSE wire stream.
 
using HttpSseWireStreamServer = HttpSseServer
 Alias for HttpSseServer, spelled to match the WireStream naming family.
 
using OnSignallingMessage = std::function< a11::Task(SignallingMessage message)>
 Async callback invoked for each inbound SignallingMessage.
 
using OnWebRtcStream = std::function< a11::Task(std::shared_ptr< WebRtcWireStream >)>
 Callback invoked with each newly negotiated peer WireStream.
 
using OnSignallingAdmission = std::function< a11::Task(SignallingAdmission)>
 Decides whether a peer may register, asynchronously.
 
using OnSignallingDeparture = std::function< void(std::string identity)>
 Notified when a registered identity's connection goes away.
 
using OnSignallingMessageFilter = std::function< absl::Status(SignallingMessage *absl_nonnull message)>
 Inspects, rewrites or refuses each inbound message before routing.
 
using OnSignallingUnroutable = std::function< absl::Status(const SignallingMessage &message)>
 Offered a message whose recipient is not connected to this server.
 
using OnWebSocketStream = std::function< a11::Task(std::shared_ptr< WebSocketWireStream >)>
 Callback invoked with a fresh WireStream for each accepted connection.
 
using OnMessage = std::function< a11::Task(std::optional< data::WireMessage > message)>
 Called for each inbound message; std::nullopt signals the peer half-closed.
 
using OnDone = std::function< a11::Task()>
 Called once, when the stream has fully finished (cleanly or via abort).
 

Enumerations

enum class  BytePacketType : std::uint8_t { kCompleteBytes = 0x00 , kByteChunk = 0x01 , kLengthSuffixedByteChunk = 0x02 }
 Packet shapes in the A11 byte-chunking wire format. More...
 
enum class  ChannelEndpointRole { kClient , kServer , kEither }
 Handshake role a binary channel endpoint is permitted to assume. More...
 
enum class  SseOutboundDelivery { kPost , kStream }
 How an SSE client hands its outbound WireMessages to the server. More...
 
enum class  CachePolicy { kStream , kVolatile , kUnset }
 How a response may be cached, which differs by what it is. More...
 
enum class  SignallingMessageType { kDescription , kCandidate , kError }
 The kind of payload a SignallingMessage carries. More...
 
enum class  TurnRelayType { kUdp , kTcp , kTls }
 Transport used to reach a TURN relay server. More...
 

Functions

absl::StatusOr< std::vector< std::string > > SplitBytesIntoPackets (std::string_view bytes, std::uint64_t transient_id, size_t packet_size)
 Split bytes into A11 packets with fixed little-endian suffixes.
 
absl::StatusOr< std::vector< std::string > > SplitOwnedBytesIntoPackets (std::string bytes, std::uint64_t transient_id, size_t packet_size)
 Split bytes the caller owns, reusing the buffer when it fits a packet.
 
absl::StatusOr< BytePacket > ParseBytePacket (std::string_view packet)
 Parse and validate one packet without retaining the input view.
 
absl::StatusOr< BytePacket > ParseOwnedBytePacket (std::string packet)
 Parse one packet, reusing its buffer as the payload.
 
std::string_view QueryOfPath (std::string_view path)
 The query part of path, without the ?.
 
bool MatchDescribePath (std::string_view path, const DescribeEndpointOptions &options, std::string *absl_nonnull name)
 Whether path addresses the describe endpoint, and what it names.
 
std::optional< a11::Task > TryDescribeOverHttp (const DescribeEndpointOptions &options, const HttpRequest &request, const std::shared_ptr< Http2ResponseWriter > &response, HttpHeaders extra_headers={})
 Answers request from options, if it is addressed to it.
 
absl::StatusOr< std::string > FileSha1 (const std::filesystem::path &path)
 Computes the SHA-1 of a file, as lowercase hex.
 
a11::Future< std::filesystem::path > Download (std::string url, DownloadOptions options)
 Downloads url to options.destination, verified and atomically.
 
a11::Future< HttpResponse > Fetch (std::string url, FetchOptions options={})
 Fetches url and buffers the whole response.
 
a11::Future< HttpResponseHead > FetchToSink (std::string url, FetchSink sink, FetchOptions options={}, OnFetchProgress on_progress={})
 Fetches url and hands the body to sink as it arrives.
 
std::uint16_t DefaultPortForScheme (std::string_view scheme)
 
absl::StatusOr< ParsedUrl > ParseUrl (std::string_view url)
 Parses an absolute http/https/ws/wss URL.
 
absl::StatusOr< ParsedUrl > ResolveReference (const ParsedUrl &base, std::string_view reference)
 Resolves reference against base, as a redirect target.
 
void NormalizeHttpHeaders (HttpHeaders *headers)
 
std::optional< std::string > GetHttpHeader (const HttpHeaders &headers, std::string_view name)
 
void EraseHttpHeader (HttpHeaders *headers, std::string_view name)
 
void SetHttpHeader (HttpHeaders *headers, std::string name, std::string value)
 
absl::Status ValidateHttpHeaders (const HttpHeaders &headers)
 
void NormalizeHttpHeaders (HttpHeaders *absl_nonnull headers)
 Lowercases every field name in headers in place.
 
void EraseHttpHeader (HttpHeaders *absl_nonnull headers, std::string_view name)
 Removes every field named name from headers.
 
void SetHttpHeader (HttpHeaders *absl_nonnull headers, std::string name, std::string value)
 Replaces any existing name fields with a single (name, value) entry.
 
void ApplyCorsHeaders (const CorsOptions &options, HttpHeaders *absl_nonnull headers)
 Adds the cross-origin headers for options to headers.
 
HttpHeaders CorsHeaders (const CorsOptions &options)
 The cross-origin headers for options, and nothing else.
 
void ApplyServerHeaders (const ServerHeaderOptions &options, CachePolicy cache, HttpHeaders *absl_nonnull headers)
 Adds the headers every response from an A11 server carries.
 
bool IsPreflight (const CorsOptions &options, std::string_view method)
 Whether method is a CORS preflight this policy should answer.
 
internal::PathMtuOptions BuildPathMtuOptions (const WebRtcConfiguration &configuration)
 
absl::StatusOr< rtc::Configuration > BuildLibDataChannelConfiguration (const WebRtcConfiguration &configuration)
 
absl::StatusOr< data::ByteMap > NormalizeWireHeaders (data::ByteMap headers)
 Validate and case-normalise a wire header map, returning the normalised copy or a non-OK status if a header name/value is invalid.
 

Variables

constexpr size_t kMergeCeilingBytes = 64 * 1024
 
constexpr std::string_view kDefaultDescribeEndpoint = "/actions"
 Default path serving the action descriptors.
 
constexpr std::string_view kSseStreamIdHeader = "x-a11-stream-id"
 Response header naming the stream id assigned to an SSE connection.
 
constexpr std::string_view kSseHttpHeaderPrefix = "x-a11-http-"
 Prefix under which application HTTP headers are tunneled over SSE.
 
constexpr std::string_view kSseOutboundModesHeader = "x-a11-outbound"
 Response header on the connect response listing the outbound delivery modes the server accepts, comma-separated – post, stream.
 
constexpr std::string_view kSseOutboundPostToken = "post"
 Token for one-POST-per-message outbound delivery.
 
constexpr std::string_view kSseOutboundStreamToken = "stream"
 Token for long-lived-request-body outbound delivery.
 
constexpr std::string_view kSseWireStreamContentType
 Content type of a streamed outbound request body.
 
constexpr std::string_view kDefaultSseConnectEndpoint = "/connect"
 Default path on which a client opens the SSE event stream.
 
constexpr std::string_view kDefaultSseMessageEndpoint
 Default message-post path template ({id} is the stream id).
 
constexpr std::string_view kServerHeaderValue = "a11"
 Value of the Server header A11's HTTP surfaces send.
 
constexpr size_t kWebRtcBaseMtu = 1280
 The MTU a WebRTC association uses until something better is confirmed.
 
constexpr size_t kWebRtcMinMtu = 512
 Smallest MTU usrsctp will accept (SCTP_SMALLEST_PMTU).
 
constexpr std::string_view kAbortStatusHeader = "x-a11-abort-status"
 Trailer key under which an aborting endpoint reports its terminal status.
 
constexpr size_t kMaxSingleMessageSize = 32 * 1024 * 1024
 Hard ceiling on the size of a single reassembled inbound WireMessage.
 

Typedef Documentation

◆ DescribeActionsHandler

using a11::net::DescribeActionsHandler = typedef std::function<absl::StatusOr<std::string>( std::string_view name, std::string_view query)>

Answers a discovery request without opening a wire stream.

Parameters
nameAction to describe, or empty for the whole collection.
queryThe URL query string, without the ?. Parsed by the implementation, which is where the request's shape is known.
Returns
The JSON body, or a status whose code becomes the HTTP status.

◆ FetchSink

using a11::net::FetchSink = typedef std::function<absl::Status(std::string_view chunk)>

Receives body chunks in order.

Returning a non-OK status cancels the response and fails the fetch with that status, which is how a sink reports that it could not write.

◆ Http2RequestHandler

using a11::net::Http2RequestHandler = typedef std::function<a11::Task( HttpRequest request, std::shared_ptr<Http2ResponseWriter> response)>

Callback dispatched for each inbound request, given a response writer.

◆ HttpHeaders

using a11::net::HttpHeaders = typedef std::vector<std::pair<std::string, std::string> >

An ordered list of (name, value) HTTP/2 header fields.

Field names are normalized to lowercase. A compact sequence preserves repeated fields and wire order without allocating a tree node per field.

◆ HttpSseWireStreamServer

Alias for HttpSseServer, spelled to match the WireStream naming family.

◆ OnDone

using a11::net::OnDone = typedef std::function<a11::Task()>

Called once, when the stream has fully finished (cleanly or via abort).

◆ OnFetchProgress

using a11::net::OnFetchProgress = typedef std::function<void(std::uint64_t bytes_done, std::uint64_t bytes_total)>

Called as a body arrives.

Parameters
bytes_doneBytes delivered to the sink so far.
bytes_totalTotal from Content-Length, or 0 when it is unknown.

◆ OnHttpSseConnect

using a11::net::OnHttpSseConnect = typedef std::function<a11::Task(std::shared_ptr<HttpSseServerWireStream>)>

Callback invoked with each accepted server-side SSE wire stream.

◆ OnMessage

using a11::net::OnMessage = typedef std::function<a11::Task(std::optional<data::WireMessage> message)>

Called for each inbound message; std::nullopt signals the peer half-closed.

Returns an awaitable the transport awaits before delivering the next message (this is where a consumer applies backpressure).

◆ OnSignallingAdmission

Decides whether a peer may register, asynchronously.

A failed task rejects the registration and its status becomes the HTTP response; an OK task admits. Asynchronous because the answer usually lives in a database, and this runs once per connection rather than per message.

◆ OnSignallingDeparture

using a11::net::OnSignallingDeparture = typedef std::function<void(std::string identity)>

Notified when a registered identity's connection goes away.

◆ OnSignallingMessage

using a11::net::OnSignallingMessage = typedef std::function<a11::Task(SignallingMessage message)>

Async callback invoked for each inbound SignallingMessage.

◆ OnSignallingMessageFilter

using a11::net::OnSignallingMessageFilter = typedef std::function<absl::Status(SignallingMessage* absl_nonnull message)>

Inspects, rewrites or refuses each inbound message before routing.

Synchronous because signalling is ordered per connection and an asynchronous filter would either reorder messages or need a queue per connection to avoid it; the things a filter actually does – rate limiting, field checks – are arithmetic. A non-OK status refuses that one message and is reported to its sender as an error message; the connection stays open.

◆ OnSignallingUnroutable

using a11::net::OnSignallingUnroutable = typedef std::function<absl::Status(const SignallingMessage& message)>

Offered a message whose recipient is not connected to this server.

The egress half of a federated fabric, paired with SignallingService::Deliver(): return OK once the message has been handed to whatever will carry it elsewhere, or a non-OK status to say it is genuinely undeliverable, which the sender is told about.

◆ OnWebRtcStream

using a11::net::OnWebRtcStream = typedef std::function<a11::Task(std::shared_ptr<WebRtcWireStream>)>

Callback invoked with each newly negotiated peer WireStream.

◆ OnWebSocketStream

using a11::net::OnWebSocketStream = typedef std::function<a11::Task(std::shared_ptr<WebSocketWireStream>)>

Callback invoked with a fresh WireStream for each accepted connection.

Enumeration Type Documentation

◆ BytePacketType

enum class a11::net::BytePacketType : std::uint8_t
strong

Packet shapes in the A11 byte-chunking wire format.

Enumerator
kCompleteBytes 
kByteChunk 
kLengthSuffixedByteChunk 

◆ CachePolicy

enum class a11::net::CachePolicy
strong

How a response may be cached, which differs by what it is.

A stream must never be cached or buffered; a document that changes when a registry changes must be revalidated rather than kept. Stating which of the two a route is, rather than spelling headers at each one, is what keeps a new route from quietly getting the wrong answer.

Enumerator
kStream 

A live stream. no-store, and a hint to intermediaries not to buffer.

kVolatile 

A document that may change at any time. no-cache: use it, but ask first.

kUnset 

Say nothing, and leave caching to whatever default applies.

◆ ChannelEndpointRole

enum class a11::net::ChannelEndpointRole
strong

Handshake role a binary channel endpoint is permitted to assume.

Enumerator
kClient 
kServer 
kEither 

◆ SignallingMessageType

The kind of payload a SignallingMessage carries.

Enumerator
kDescription 
kCandidate 
kError 

◆ SseOutboundDelivery

enum class a11::net::SseOutboundDelivery
strong

How an SSE client hands its outbound WireMessages to the server.

The inbound direction is always the SSE event stream. Only the outbound one has a choice, and it is a reachability/throughput trade rather than a correctness one – the server accepts both, on the same endpoint, and a stream and a series of POSTs deliver the same messages.

Enumerator
kPost 

One HTTP POST per message.

Browsers can use this mode through fetch(). A11 issues POSTs concurrently up to max_concurrent_posts because WireMessages have no global order. Outstanding messages complete before a half-close; an abort is sent before messages still in flight.

kStream 

One long-lived request body carrying every outbound message.

HTTP/2 DATA frames or an HTTP/1.1 chunked body, framed as kSseWireStreamContentType describes. Removes the one-request-per-message ceiling, and ordering comes from the stream itself. Needs a client that can write a request body incrementally, which fetch() cannot do portably – so this is for C++, Python and other capable backends. Falls back to kPost against a server that does not advertise stream in kSseOutboundModesHeader.

◆ TurnRelayType

enum class a11::net::TurnRelayType
strong

Transport used to reach a TURN relay server.

Enumerator
kUdp 
kTcp 
kTls 

Function Documentation

◆ ApplyCorsHeaders()

void a11::net::ApplyCorsHeaders ( const CorsOptions &  options,
HttpHeaders *absl_nonnull  headers 
)

Adds the cross-origin headers for options to headers.

Vary: Origin comes with them whenever the policy names a specific origin, because a cache that kept one origin's response and served it to another would be handing out a header the second origin must not see.

◆ ApplyServerHeaders()

void a11::net::ApplyServerHeaders ( const ServerHeaderOptions &  options,
CachePolicy  cache,
HttpHeaders *absl_nonnull  headers 
)

Adds the headers every response from an A11 server carries.

Idempotent, and never replaces a header already set: a route that has said something specific – a content type, its own cache policy – keeps it.

Parameters
optionsThe surface's policy.
cacheWhat kind of response this is.
headersHeaders to add to.

◆ BuildLibDataChannelConfiguration()

absl::StatusOr< rtc::Configuration > a11::net::BuildLibDataChannelConfiguration ( const WebRtcConfiguration &  configuration)

◆ BuildPathMtuOptions()

internal::PathMtuOptions a11::net::BuildPathMtuOptions ( const WebRtcConfiguration &  configuration)

◆ CorsHeaders()

HttpHeaders a11::net::CorsHeaders ( const CorsOptions &  options)

The cross-origin headers for options, and nothing else.

For a route that builds its headers from scratch and wants the CORS half. ApplyServerHeaders adds these too.

◆ DefaultPortForScheme()

std::uint16_t a11::net::DefaultPortForScheme ( std::string_view  scheme)
Returns
The default port for scheme, or 0 when the scheme is unknown.

◆ Download()

a11::Future< std::filesystem::path > a11::net::Download ( std::string  url,
DownloadOptions  options 
)

Downloads url to options.destination, verified and atomically.

Returns immediately when the destination already exists and either no digest was given or its digest matches. Otherwise streams the body to a temporary sibling, verifies, and renames.

Parameters
urlAbsolute http/https URL.
optionsDestination, expected digest, and request settings.
Returns
An awaitable resolving to the destination path, or a status: InvalidArgument for no destination, DataLoss when the digest does not match (the temporary is removed), or whatever Fetch reports. A failed download never leaves the temporary behind.

◆ EraseHttpHeader() [1/2]

void a11::net::EraseHttpHeader ( HttpHeaders *absl_nonnull  headers,
std::string_view  name 
)

Removes every field named name from headers.

◆ EraseHttpHeader() [2/2]

void a11::net::EraseHttpHeader ( HttpHeaders *  headers,
std::string_view  name 
)

◆ Fetch()

a11::Future< HttpResponse > a11::net::Fetch ( std::string  url,
FetchOptions  options = {} 
)

Fetches url and buffers the whole response.

Parameters
urlAbsolute http/https URL.
optionsWhat to request.
Returns
An awaitable resolving to the response, or a status: InvalidArgument for an unusable URL, OutOfRange when the body exceeds transport.max_response_body_size, the mapped status for a 4xx/5xx, or DeadlineExceeded on timeout.

◆ FetchToSink()

a11::Future< HttpResponseHead > a11::net::FetchToSink ( std::string  url,
FetchSink  sink,
FetchOptions  options = {},
OnFetchProgress  on_progress = {} 
)

Fetches url and hands the body to sink as it arrives.

The body is never accumulated, so this is the entry point for a response too large to hold. Redirect responses are followed without ever reaching the sink, so sink sees the body of exactly one response.

Parameters
urlAbsolute http/https URL.
sinkReceives body chunks in order.
optionsWhat to request.
on_progressOptional progress callback, invoked from the fetching fiber between chunks.
Returns
An awaitable resolving to the final response's status and headers.

◆ FileSha1()

absl::StatusOr< std::string > a11::net::FileSha1 ( const std::filesystem::path &  path)

Computes the SHA-1 of a file, as lowercase hex.

Exposed because a caller checking a cache it did not populate wants the same digest this module verifies with.

Parameters
pathFile to hash.
Returns
The hex digest, or NotFound / a read error status.

◆ GetHttpHeader()

std::optional< std::string > a11::net::GetHttpHeader ( const HttpHeaders &  headers,
std::string_view  name 
)
Returns
The first value for name, or nullopt if absent.

◆ IsPreflight()

bool a11::net::IsPreflight ( const CorsOptions &  options,
std::string_view  method 
)

Whether method is a CORS preflight this policy should answer.

◆ MatchDescribePath()

bool a11::net::MatchDescribePath ( std::string_view  path,
const DescribeEndpointOptions &  options,
std::string *absl_nonnull  name 
)

Whether path addresses the describe endpoint, and what it names.

Matches both /actions and /actions/<name>, so one predicate answers the collection and the item route.

Parameters
pathRequest path, already stripped of its query.
optionsThe endpoint's configuration.
nameSet to the named action, or empty for the collection.
Returns
Whether path is this endpoint at all.

◆ NormalizeHttpHeaders() [1/2]

void a11::net::NormalizeHttpHeaders ( HttpHeaders *absl_nonnull  headers)

Lowercases every field name in headers in place.

◆ NormalizeHttpHeaders() [2/2]

void a11::net::NormalizeHttpHeaders ( HttpHeaders *  headers)

◆ NormalizeWireHeaders()

absl::StatusOr< data::ByteMap > a11::net::NormalizeWireHeaders ( data::ByteMap  headers)

Validate and case-normalise a wire header map, returning the normalised copy or a non-OK status if a header name/value is invalid.

◆ ParseBytePacket()

absl::StatusOr< BytePacket > a11::net::ParseBytePacket ( std::string_view  packet)

Parse and validate one packet without retaining the input view.

◆ ParseOwnedBytePacket()

absl::StatusOr< BytePacket > a11::net::ParseOwnedBytePacket ( std::string  packet)

Parse one packet, reusing its buffer as the payload.

Removes the metadata suffix in place and returns the remaining owned payload.

◆ ParseUrl()

absl::StatusOr< ParsedUrl > a11::net::ParseUrl ( std::string_view  url)

Parses an absolute http/https/ws/wss URL.

The scheme is matched case-insensitively and stored lowercase. An absent port takes the scheme's default. A trailing fragment is discarded.

Parameters
urlThe URL to parse.
Returns
The parsed URL, or InvalidArgument when the scheme is not one of the four, the authority is missing, or the port is not a number.

◆ QueryOfPath()

std::string_view a11::net::QueryOfPath ( std::string_view  path)

The query part of path, without the ?.

◆ ResolveReference()

absl::StatusOr< ParsedUrl > a11::net::ResolveReference ( const ParsedUrl &  base,
std::string_view  reference 
)

Resolves reference against base, as a redirect target.

Handles the four forms a Location header uses in practice: an absolute URL, a protocol-relative //host/path, an absolute path /path, and a relative path resolved against base's directory. Enough of RFC 3986 section 5 to follow redirects correctly, and no more.

Parameters
baseThe URL the reference was received from.
referenceThe reference to resolve.
Returns
The resolved absolute URL, or InvalidArgument when reference is empty or names an unsupported scheme.

◆ SetHttpHeader() [1/2]

void a11::net::SetHttpHeader ( HttpHeaders *absl_nonnull  headers,
std::string  name,
std::string  value 
)

Replaces any existing name fields with a single (name, value) entry.

◆ SetHttpHeader() [2/2]

void a11::net::SetHttpHeader ( HttpHeaders *  headers,
std::string  name,
std::string  value 
)

◆ SplitBytesIntoPackets()

absl::StatusOr< std::vector< std::string > > a11::net::SplitBytesIntoPackets ( std::string_view  bytes,
std::uint64_t  transient_id,
size_t  packet_size 
)

Split bytes into A11 packets with fixed little-endian suffixes.

◆ SplitOwnedBytesIntoPackets()

absl::StatusOr< std::vector< std::string > > a11::net::SplitOwnedBytesIntoPackets ( std::string  bytes,
std::uint64_t  transient_id,
size_t  packet_size 
)

Split bytes the caller owns, reusing the buffer when it fits a packet.

Appends metadata to the owned buffer when the message fits one packet. The multi-packet result matches SplitBytesIntoPackets.

◆ TryDescribeOverHttp()

std::optional< a11::Task > a11::net::TryDescribeOverHttp ( const DescribeEndpointOptions &  options,
const HttpRequest &  request,
const std::shared_ptr< Http2ResponseWriter > &  response,
HttpHeaders  extra_headers = {} 
)

Answers request from options, if it is addressed to it.

The whole endpoint, for whichever server holds the port. GET and HEAD are answered with the JSON document; a failing describer's status code becomes the HTTP one, so an unknown action is a 404 with the describer's own message.

Parameters
optionsThe endpoint's configuration; a disabled one matches nothing.
requestThe inbound request, query string included.
responseWhere to write the answer.
extra_headersHeaders to include, typically CORS.
Returns
The task answering it, or nullopt when this is not that endpoint – which leaves the caller's own routing, and its own 404, in charge.

◆ ValidateHttpHeaders()

absl::Status a11::net::ValidateHttpHeaders ( const HttpHeaders &  headers)
Returns
OK if the header list is well-formed.

Variable Documentation

◆ kAbortStatusHeader

constexpr std::string_view a11::net::kAbortStatusHeader = "x-a11-abort-status"
inlineconstexpr

Trailer key under which an aborting endpoint reports its terminal status.

◆ kDefaultDescribeEndpoint

constexpr std::string_view a11::net::kDefaultDescribeEndpoint = "/actions"
inlineconstexpr

Default path serving the action descriptors.

◆ kDefaultSseConnectEndpoint

constexpr std::string_view a11::net::kDefaultSseConnectEndpoint = "/connect"
inlineconstexpr

Default path on which a client opens the SSE event stream.

◆ kDefaultSseMessageEndpoint

constexpr std::string_view a11::net::kDefaultSseMessageEndpoint
inlineconstexpr
Initial value:
=
"/streams/{id}/message"

Default message-post path template ({id} is the stream id).

◆ kMaxSingleMessageSize

constexpr size_t a11::net::kMaxSingleMessageSize = 32 * 1024 * 1024
inlineconstexpr

Hard ceiling on the size of a single reassembled inbound WireMessage.

◆ kMergeCeilingBytes

constexpr size_t a11::net::kMergeCeilingBytes = 64 * 1024
constexpr

◆ kServerHeaderValue

constexpr std::string_view a11::net::kServerHeaderValue = "a11"
inlineconstexpr

Value of the Server header A11's HTTP surfaces send.

◆ kSseHttpHeaderPrefix

constexpr std::string_view a11::net::kSseHttpHeaderPrefix = "x-a11-http-"
inlineconstexpr

Prefix under which application HTTP headers are tunneled over SSE.

◆ kSseOutboundModesHeader

constexpr std::string_view a11::net::kSseOutboundModesHeader = "x-a11-outbound"
inlineconstexpr

Response header on the connect response listing the outbound delivery modes the server accepts, comma-separated – post, stream.

A server that omits it is understood to accept post only, which is what every deployed SSE server did before streamed delivery existed.

◆ kSseOutboundPostToken

constexpr std::string_view a11::net::kSseOutboundPostToken = "post"
inlineconstexpr

Token for one-POST-per-message outbound delivery.

◆ kSseOutboundStreamToken

constexpr std::string_view a11::net::kSseOutboundStreamToken = "stream"
inlineconstexpr

Token for long-lived-request-body outbound delivery.

◆ kSseStreamIdHeader

constexpr std::string_view a11::net::kSseStreamIdHeader = "x-a11-stream-id"
inlineconstexpr

Response header naming the stream id assigned to an SSE connection.

◆ kSseWireStreamContentType

constexpr std::string_view a11::net::kSseWireStreamContentType
inlineconstexpr
Initial value:
=
"application/vnd.a11.wire-stream+json"

Content type of a streamed outbound request body.

The body is a sequence of frames, each a four-byte little-endian payload length followed by that many bytes of the JSON WireMessage encoding the POST route carries one of. HTTP/2 sends it as DATA frames and HTTP/1.1 as a chunked body; neither framing is a message boundary, which is why the length prefix is there.

◆ kWebRtcBaseMtu

constexpr size_t a11::net::kWebRtcBaseMtu = 1280
inlineconstexpr

The MTU a WebRTC association uses until something better is confirmed.

The 1280-byte value follows the IPv6 minimum link MTU and RFC 8261's SCTP fallback. Path MTU discovery may confirm a larger value.

◆ kWebRtcMinMtu

constexpr size_t a11::net::kWebRtcMinMtu = 512
inlineconstexpr

Smallest MTU usrsctp will accept (SCTP_SMALLEST_PMTU).