Skip to content

Instantly share code, notes, and snippets.

@Neopallium
Created August 31, 2018 14:51
Show Gist options
  • Save Neopallium/2bc4755bbbeca88093661ebd12489276 to your computer and use it in GitHub Desktop.
Save Neopallium/2bc4755bbbeca88093661ebd12489276 to your computer and use it in GitHub Desktop.
test to show connection leaking in actix-web
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