@@ -59,22 +59,28 @@ impl Request {
59
59
}
60
60
}
61
61
62
- #[ doc( hidden) ]
62
+ /// Sets a string representation of the peer address of this
63
+ /// request. This might take the form of an ip/fqdn and port or a
64
+ /// local socket address.
63
65
pub fn set_peer_addr ( & mut self , peer_addr : Option < impl std:: string:: ToString > ) {
64
66
self . peer_addr = peer_addr. map ( |addr| addr. to_string ( ) ) ;
65
67
}
66
68
67
- #[ doc( hidden) ]
69
+ /// Sets a string representation of the local address that this
70
+ /// request was received on. This might take the form of an ip/fqdn and
71
+ /// port, or a local socket address.
68
72
pub fn set_local_addr ( & mut self , local_addr : Option < impl std:: string:: ToString > ) {
69
73
self . local_addr = local_addr. map ( |addr| addr. to_string ( ) ) ;
70
74
}
71
75
72
- /// Get the peer socket address for the underlying transport, if appropriate
76
+ /// Get the peer socket address for the underlying transport, if
77
+ /// that information is available for this request.
73
78
pub fn peer_addr ( & self ) -> Option < & str > {
74
79
self . peer_addr . as_deref ( )
75
80
}
76
81
77
- /// Get the local socket address for the underlying transport, if appropriate
82
+ /// Get the local socket address for the underlying transport, if
83
+ /// that information is available for this request.
78
84
pub fn local_addr ( & self ) -> Option < & str > {
79
85
self . local_addr . as_deref ( )
80
86
}
@@ -84,9 +90,7 @@ impl Request {
84
90
self . forwarded_for ( ) . or ( self . peer_addr ( ) )
85
91
}
86
92
87
- /// Parses the Forwarded or X-Forwarded-For headers.
88
- /// The returned String will either be an IP address or a domain and an optional port.
89
- pub fn forwarded_for ( & self ) -> Option < & str > {
93
+ fn forwarded_for ( & self ) -> Option < & str > {
90
94
if let Some ( header) = self . header ( & "Forwarded" . parse ( ) . unwrap ( ) ) {
91
95
header. as_str ( ) . split ( ";" ) . find_map ( |key_equals_value| {
92
96
let parts = key_equals_value. split ( "=" ) . collect :: < Vec < _ > > ( ) ;
0 commit comments