Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More elaborate custom server name #195

Closed
ghost opened this issue Mar 13, 2023 · 1 comment · Fixed by #269
Closed

More elaborate custom server name #195

ghost opened this issue Mar 13, 2023 · 1 comment · Fixed by #269

Comments

@ghost
Copy link

ghost commented Mar 13, 2023

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

@ghost ghost changed the title More elaborate custom SNIs More elaborate custom server name Mar 13, 2023
@djc
Copy link
Member

djc commented Mar 13, 2023

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>.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant