perf: remove format for X-Forwarded-For header (#25)

This commit is contained in:
Christof Weickhardt 2022-04-13 04:25:39 +02:00 committed by GitHub
parent 4b3e3ffda1
commit c25de2e313
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -215,9 +215,15 @@ fn create_proxied_request<B>(
entry.insert(client_ip.to_string().parse()?);
}
hyper::header::Entry::Occupied(mut entry) => {
let addr = format!("{}, {}", entry.get().to_str()?, client_ip);
entry.insert(addr.parse()?);
hyper::header::Entry::Occupied(entry) => {
let client_ip_str = client_ip.to_string();
let mut addr =
String::with_capacity(entry.get().as_bytes().len() + 2 + client_ip_str.len());
addr.push_str(std::str::from_utf8(entry.get().as_bytes()).unwrap());
addr.push(',');
addr.push(' ');
addr.push_str(&client_ip_str);
}
}