rusoto
rusoto copied to clipboard
Allow initialising HttpClient with a custom HttpsConnector
Currently, it only calls HttpsConnector::new()
-- it'll be good to have an alternative where the caller can pass in the connector.
This is useful e.g. if one doesn't directly connect to the service via TCP, but is proxied (so one needs to build TlsConnector
over a different stream type and create HttpsConnector
with that)
You should be able to use SomeClient.new_with_client()
(instead of SomeClient.new()
) and pass in your own Client
.
I believe you will also need to construct a CredentialsProvider in this case too.
For example, I use this to allow my application to connect to via a corporate proxy server (where SomeClient
is the Rusoto Client you want to use):
let https = HttpsConnector::new();
let proxy_connector = ProxyConnector::from_proxy(https, Proxy::new(Intercept::All, proxy_url))?;
let http_client = HttpClient::from_connector(proxy_connector);
// replace this with whatever you want, I stole it from rosoto_core's Client
let credentials_provider = DefaultCredentialsProvider::new().expect("failed to create credentials provider");
let client = Client::new_with(credential_provider, http_client);
let some_client = SomeClient::new_with_client(client, region);
(I apologize if this code isn't perfect, I adapted this from an existing/working application, but I have a bunch of other crazy stuff in there you probably don't care about like determining the proxy URL and credential loading acrobatics).