From 1fc91880d8b9fce8aa39b2d806d1a1f23ac7e796 Mon Sep 17 00:00:00 2001 From: Shautvast Date: Fri, 6 Feb 2026 15:38:16 +0100 Subject: [PATCH] #6 writing a response --- src/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 618042a..1232397 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,4 @@ -use std::io::Read; +use std::io::{Read, Write}; use std::net::{TcpListener, TcpStream}; fn main() -> std::io::Result<()> { @@ -14,5 +14,9 @@ fn handle_connection(mut stream: TcpStream) -> std::io::Result<()>{ let mut buffer = [0; 1024]; stream.read(&mut buffer)?; println!("Request: {}", String::from_utf8_lossy(&buffer[..])); + + let response = "HTTP/1.1 200 OK\r\n\r\n"; + stream.write(response.as_bytes())?; + stream.flush()?; Ok(()) }