pub struct Handshake {
pub request: Request,
pub response: Response,
pub peer_addr: Option<SocketAddr>,
pub local_addr: Option<SocketAddr>,
}
Expand description
A struct representing the two halves of the WebSocket handshake.
Fields
request: Request
The HTTP request sent to begin the handshake.
response: Response
The HTTP response from the server confirming the handshake.
peer_addr: Option<SocketAddr>
The socket address of the other endpoint. This address may be an intermediary such as a proxy server.
local_addr: Option<SocketAddr>
The socket address of this endpoint.
Implementations
sourceimpl Handshake
impl Handshake
sourcepub fn remote_addr(&self) -> Result<Option<String>>
pub fn remote_addr(&self) -> Result<Option<String>>
Get the IP address of the remote connection.
This is the preferred method of obtaining the client’s IP address. It will attempt to retrieve the most likely IP address based on request headers, falling back to the address of the peer.
Note
This assumes that the peer is a client. If you are implementing a
WebSocket client and want to obtain the address of the server, use
Handshake::peer_addr
instead.
This method does not ensure that the address is a valid IP address.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Handshake
impl Send for Handshake
impl Sync for Handshake
impl Unpin for Handshake
impl UnwindSafe for Handshake
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more