pub struct ForwardedHeaderValue { /* private fields */ }
Expand description
This structure represents the contents of the Forwarded header
It should contain one or more ForwardedStanzas
Implementations§
Source§impl ForwardedHeaderValue
impl ForwardedHeaderValue
Sourcepub fn remotest(&self) -> &ForwardedStanza
pub fn remotest(&self) -> &ForwardedStanza
Get the value farthest from this system (the left-most value)
This may represent the remote client
Sourcepub fn into_remotest(self) -> ForwardedStanza
pub fn into_remotest(self) -> ForwardedStanza
Get the value farthest from this system (the left-most value), consuming this object
This may represent the remote client
Sourcepub fn proximate(&self) -> &ForwardedStanza
pub fn proximate(&self) -> &ForwardedStanza
Get the value closest to this system (the right-most value).
This is typically the only trusted value in a well-architected system.
Sourcepub fn into_proximate(self) -> ForwardedStanza
pub fn into_proximate(self) -> ForwardedStanza
Get the value closest to this system (the right-most value), consuming this object
This is typically the only trusted value in a well-architected system.
Sourcepub fn iter(&self) -> ForwardedHeaderValueIterator<'_> ⓘ
pub fn iter(&self) -> ForwardedHeaderValueIterator<'_> ⓘ
Iterate through all ForwardedStanzas
Sourcepub fn proximate_forwarded_for_ip(&self) -> Option<IpAddr>
pub fn proximate_forwarded_for_ip(&self) -> Option<IpAddr>
Return the rightmost non-empty forwarded-for IP, if one is present
Sourcepub fn remotest_forwarded_for_ip(&self) -> Option<IpAddr>
pub fn remotest_forwarded_for_ip(&self) -> Option<IpAddr>
Return the leftmost forwarded-for IP, if one is present
Sourcepub fn from_forwarded(
header_value: &str,
) -> Result<Self, ForwardedHeaderValueParseError>
pub fn from_forwarded( header_value: &str, ) -> Result<Self, ForwardedHeaderValueParseError>
Parse the value from a Forwarded header into this structure
§Example
let input = "for=1.2.3.4;by=\"[::1]:1234\"";
let value = ForwardedHeaderValue::from_forwarded(input)?;
assert_eq!(value.len(), 1);
assert_eq!(value.remotest_forwarded_for_ip(), Some("1.2.3.4".parse()?));
Sourcepub fn from_x_forwarded_for(
header_value: &str,
) -> Result<Self, ForwardedHeaderValueParseError>
pub fn from_x_forwarded_for( header_value: &str, ) -> Result<Self, ForwardedHeaderValueParseError>
Parse the value from an X-Forwarded-For header into this structure
§Example
let input = "1.2.3.4, 5.6.7.8";
let value = ForwardedHeaderValue::from_x_forwarded_for(input)?;
assert_eq!(value.len(), 2);
assert_eq!(value.remotest_forwarded_for_ip(), Some("1.2.3.4".parse()?));
assert_eq!(value.proximate_forwarded_for_ip(), Some("5.6.7.8".parse()?));