Created
August 31, 2018 14:51
-
-
Save Neopallium/2bc4755bbbeca88093661ebd12489276 to your computer and use it in GitHub Desktop.
test to show connection leaking in actix-web
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::io; | |
use std::io::prelude::*; | |
use std::net::{Shutdown, TcpStream}; | |
fn main() -> io::Result<()> { | |
let mut stream = TcpStream::connect("127.0.0.1:8080").expect("Couldn't connect to the server..."); | |
stream.write(b"GET / HTTP/1.1\r\nHost: localhost:8080\r\n\r\n").expect("write"); | |
// shutdown write side of TCP connection right after sending the HTTP request. | |
stream.shutdown(Shutdown::Write).expect("shutdown call failed"); | |
let mut buf = String::new(); | |
stream.read_to_string(&mut buf)?; | |
Ok(()) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment