我有
hyper = "0.10"
以下代码:
let client = Client::new(); let mut res = client.get("https://google.com").send().unwrap();
Rust给我错误消息,好像它没有SSL支持:
Http的方案无效
这是在Debian jessie的Rust 1.14.0上.
如何让Hyper将SSL连接到HTTPS URL?
试试这个:
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(); }
主要取自这个答案.缺少的是这Client::with_connector
件作品.