15 lines
463 B
Rust
15 lines
463 B
Rust
use native_tls::TlsConnector;
|
|
use std::io::{Read, Write};
|
|
use std::net::TcpStream;
|
|
|
|
fn main() {
|
|
let connector = TlsConnector::new().unwrap();
|
|
|
|
let stream = TcpStream::connect("google.com:443").unwrap();
|
|
let mut stream = connector.connect("google.com", stream).unwrap();
|
|
|
|
stream.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap();
|
|
let mut res = vec![];
|
|
stream.read_to_end(&mut res).unwrap();
|
|
println!("{}", String::from_utf8_lossy(&res));
|
|
}
|