MCPcopy Create free account
hub / github.com/Rust-Web-Development/code / handle_stream

Function handle_stream

ch_01/minimal-tcp/src/main.rs:11–19  ·  view source on GitHub ↗
(mut stream: TcpStream)

Source from the content-addressed store, hash-verified

9}
10
11fn handle_stream(mut stream: TcpStream) {
12 let mut buffer = [0; 1024];
13 stream.read_exact(&mut buffer).unwrap();
14 println!("Request: {}", String::from_utf8_lossy(&buffer[..]));
15
16 let response = "HTTP/1.1 200 OK\r\n\r\n";
17 stream.write_all(response.as_bytes()).unwrap();
18 stream.flush().unwrap();
19}

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected