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

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.