pub struct AcceptOptions {
pub allow_implicit_codec: bool,
pub allowed_origins: Option<Vec<String>>,
}Expand description
Options controlling how the handshake picks a subprotocol to echo when the
handler’s selector declines (see accept_with_options).
Fields§
§allow_implicit_codec: boolWhen the selector returns None and the client did not offer
DEFAULT_SUBPROTOCOL (h2ts), accept the client’s first offered
subprotocol (or, if it offered none, complete with no subprotocol)
instead of rejecting the handshake.
Off by default: a client that speaks neither h2ts nor a
handler-selected protocol is rejected with
WebSocketError::UnsupportedSubprotocol. Turn this on for a
codec-agnostic tunnel that accepts whatever framing the client offered
(e.g. a raw/binary tunnel, or a websockify-style binary client).
allowed_origins: Option<Vec<String>>Opt-in Origin allowlist (Cross-Site WebSocket Hijacking defence). When
Some, only handshakes whose Origin header matches one of these entries
(ASCII case-insensitive, e.g. https://app.example.com) are accepted;
everything else — including a missing Origin — is rejected with a 403
(WebSocketError::ForbiddenOrigin).
None (the default) accepts any origin. This mirrors nginx, which does no
Origin validation by default and leaves it as an opt-in allowlist; a
browser always sends Origin, so a legitimate browser client is unaffected.
Trait Implementations§
Source§impl Clone for AcceptOptions
impl Clone for AcceptOptions
Source§fn clone(&self) -> AcceptOptions
fn clone(&self) -> AcceptOptions
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more