pub struct WebSocketOptions<'a> {
pub path: &'a str,
pub host: &'a str,
pub origin: &'a str,
pub sub_protocols: Option<&'a [&'a str]>,
pub additional_headers: Option<&'a [&'a str]>,
}
Expand description
Websocket options used by a websocket client to initiate an opening handshake with a websocket server
Fields§
§path: &'a str
The request uri (e.g. /chat?id=123
) of the GET method used to identify the endpoint of the
websocket connection. This allows multiple domains to be served by a single server.
This could also be used to send identifiable information about the client
host: &'a str
The hostname (e.g. server.example.com
) is used so that both the client and the server
can verify that they agree on which host is in use
origin: &'a str
The origin (e.g. http://example.com
) is used to protect against unauthorized
cross-origin use of a WebSocket server by scripts using the WebSocket API in a web
browser. This field is usually only set by browser clients but servers may require it
so it has been exposed here.
sub_protocols: Option<&'a [&'a str]>
A list of requested sub protocols in order of preference. The server should return the first sub protocol it supports or none at all. A sub protocol can be anything agreed between the server and client
additional_headers: Option<&'a [&'a str]>
Any additional headers the server may require that are not part of the websocket
spec. These should be fully formed http headers without the \r\n
(e.g. MyHeader: foo
)