#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
SimpleLogger::new().init().unwrap();
let target_stream = TcpStream::connect("finance.yahoo.com:443").await?;
let (mut request_sender, connection) = conn::handshake(target_stream).await?;
// spawn a task to poll the connection and drive the HTTP state
tokio::spawn(async move {
if let Err(e) = connection.await {
eprintln!("Error in connection: {}", e);
}
});
let request = Request::builder()
// We need to manually add the host header because SendRequest does not
.header("Host", "finance.yahoo.com")
.method("GET")
.body(Body::empty())?;
let response = request_sender.send_request(request).await?;
assert!(response.status() == StatusCode::OK);
Ok(())
}
Hi guys, how can I add tls to this code, I know I could use hyper::client, or hyper_tls::httpsconnector,
But I want to know more about low-level stuff.
Thank you very much for your help.
Best