pub struct ConnectionInfo { /* private fields */ }Expand description
HttpRequest connection information
Values from the Forwarded and X-Forwarded-* headers are used only as
allowed by the application’s ForwardedPolicy.
Implementations§
Source§impl ConnectionInfo
impl ConnectionInfo
Sourcepub fn get<'a>(req: &'a RequestHead, cfg: &'a WebAppConfig) -> Ref<'a, Self>
pub fn get<'a>(req: &'a RequestHead, cfg: &'a WebAppConfig) -> Ref<'a, Self>
Create ConnectionInfo instance for a request.
Sourcepub fn scheme(&self) -> &str
pub fn scheme(&self) -> &str
Scheme of the request.
Scheme is resolved from the following sources, in this order:
ForwardedorX-Forwarded-Proto, if allowed by theForwardedPolicy- Uri or the HTTP/2
:scheme, seeRequestHead::scheme httpsif the server is configured as secure,httpotherwise
Sourcepub fn host(&self) -> &str
pub fn host(&self) -> &str
Hostname of the request.
Hostname is resolved from the following sources, in this order:
ForwardedorX-Forwarded-Host, if allowed by theForwardedPolicy- Uri or the HTTP/2
:authority, seeRequestHead::authority - Host
- Server hostname
Header values that are not a valid host[:port] are skipped.
Sourcepub fn remote(&self) -> Option<&str>
pub fn remote(&self) -> Option<&str>
Address of the client that initiated the HTTP request.
The address is resolved from the following sources, in this order:
ForwardedorX-Forwarded-For, if allowed by theForwardedPolicy- peer address of the connection
Forwarded values are returned as sent by the proxy, for example
192.0.2.1, [2001:db8::1]:4711 or unknown. With the default policy
this is always the peer address. Use
HttpRequest::peer_addr() for
the address of the connection itself.