pub enum WebSocketError {
NotUpgradeRequest,
UnsupportedSubprotocol,
Upgrade(Error),
}Expand description
Errors from the WebSocket handshake.
Variants§
NotUpgradeRequest
The request was not a valid WebSocket upgrade (missing/invalid
Upgrade / Connection / Sec-WebSocket-Key).
UnsupportedSubprotocol
The client offered no subprotocol the server accepts: it didn’t offer
DEFAULT_SUBPROTOCOL (h2ts), the handler’s selector declined, and
AcceptOptions::allow_implicit_codec was off. Reject it with a 400
(see WebSocketError::rejection_response).
Upgrade(Error)
hyper failed to upgrade the connection after the 101 was sent.
Implementations§
Source§impl WebSocketError
impl WebSocketError
Sourcepub fn rejection_response(&self) -> Response<Empty<Bytes>>
pub fn rejection_response(&self) -> Response<Empty<Bytes>>
The HTTP response to reject this handshake with, for the pre-upgrade
errors returned by accept / accept_with / accept_with_options:
426 Upgrade Required for a non-WebSocket request, 400 Bad Request for
an unsupported subprotocol. (An Upgrade error
happens after the 101 and has no meaningful rejection response; it maps
to 500 for completeness.)
let (response, ws_fut) = match h2ts_server::accept(&mut req) {
Ok(pair) => pair,
Err(err) => return Ok(err.rejection_response()), // send the 4xx back
};Trait Implementations§
Source§impl Debug for WebSocketError
impl Debug for WebSocketError
Source§impl Display for WebSocketError
impl Display for WebSocketError
Source§impl Error for WebSocketError
impl Error for WebSocketError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()