I have
hyper = "0.10"
And the following code:
let client = Client::new();
let mut res = client.get("https://google.com").send().unwrap();
Rust gives me the error message, as if it doesn't have SSL support:
Invalid scheme for Http
This is on Rust 1.14.0 on Debian jessie.
How do I get Hyper to connect with SSL to an HTTPS URL?
Try this:
extern crate hyper;
extern crate hyper_native_tls;
use hyper::Client;
use hyper::net::HttpsConnector;
use hyper_native_tls::NativeTlsClient;
fn main() {
let ssl = NativeTlsClient::new().unwrap();
let connector = HttpsConnector::new(ssl);
let client = Client::with_connector(connector);
let mut res = client.get("https://google.com").send().unwrap();
}
Mostly taken from this answer. What was missing was the Client::with_connector
piece.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With