hyper-rustls
hyper-rustls copied to clipboard
confusion on `HttpsConnetor::wrap_connector`
Hey,
I thought the following would work to make https or http
calls:
let mut connector = HttpConnector::new();
let connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.https_or_http()
.enable_http1()
.wrap_connector(connector),
let client = Client::builder().build::<_, hyper::Body>(connector);
but hyper reports back that https
is not valid.
thread 'main' panicked at 'called Result::unwrap()
on an Err
value: Transport(HTTP error: error trying to connect: invalid URL, scheme is not http)'
Ah I see the entire connector config is used then I guess
I'm not sure what the issue is here, or if there was an issue in hyper-rustls at all. Is this actionable for us?
Since the original poster hasn't replied with more detail I'm going to close this issue as unactionable for the time being. Thanks.
Hey again.
Sorry forgot to answer and the issue was that the HttpConnector
enforces the URI to be http and https is denied by default. Thus, the following fixes the panic:
let mut connector = HttpConnector::new();
connector.enforce_http(false);
let connector = hyper_rustls::HttpsConnectorBuilder::new()
.with_native_roots()
.https_or_http()
.enable_http1()
.wrap_connector(connector),
let client = Client::builder().build::<_, hyper::Body>(connector);
It's easy to get wrong and because this repo connector is a HTTPS, it would makes sense to me to set connector.enforce_http(false)
in HttpsConnectorBuilder::wrap_connector
to allow HTTPs URIs by default but since it's generic it's probably not possible.