We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 170ee36 commit 3145e3aCopy full SHA for 3145e3a
1 file changed
src/http/request.rs
@@ -278,11 +278,13 @@ fn clear_path_end_slash(input: &str) -> &str {
278
}
279
280
fn trust_addr_proxy(headers : &CIHashMap<String>,remote_addr : &str) -> String {
281
- if let Some(remote_ip) = headers.get("X-Real-IP") {
282
- remote_ip.to_string()
283
- } else {
284
- remote_addr.to_string()
285
- }
+ headers.get("X-Real-IP")
+ .map(|s| s.as_str())
+ .or_else(|| {
+ headers.get("X-Forwarded-For").and_then(|s| {
+ s.split(',').next().map(|ip| ip.trim())
286
+ })
287
+ }).unwrap_or(remote_addr).to_string()
288
289
290
//form-data-parser
0 commit comments