hyper-rustls
hyper-rustls copied to clipboard
More elaborate custom server name
let https = HttpsConnectorBuilder::new()
.with_native_roots()
.https_only()
.with_server_name("override_server_name")
.enable_http1()
.build();
// change it to
let https = HttpsConnectorBuilder::new()
.with_native_roots()
.https_only()
.with_server_name(|request| {
// Compute server name
return "override_server_name";
})
.enable_http1()
.build();
This allows different server names to be injected for different ip requests
Makes sense, I think. Would you like to submit a PR? I think we can change it to do something like this:
trait ServerNameResolver {
fn resolve(&self, uri: Uri) -> Result<ServerName, Box<dyn std::error::Error + Send + Sync>>;
}
It should probably come with impls for String (current approach) and impl Fn(uri: Uri) -> Result<ServerName, Box<dyn std::error::Error + Send + Sync>.