feat: response threaded

This commit is contained in:
2025-07-22 22:06:49 +02:00
parent 391c9098a6
commit 645f53d13e

View File

@@ -1,7 +1,7 @@
use std::collections::HashMap;
use std::fs;
use std::io::prelude::*;
use std::net::{SocketAddr, TcpListener, TcpStream};
use std::{fs, thread};
use super::*;
@@ -110,12 +110,15 @@ impl HttpApp<'_> {
for stream in listener.incoming() {
let mut _stream = stream.unwrap();
println!("Connection established!");
let response = self.process_petition(&mut _stream);
// TODO: manage error case
let _amount = _stream.write(response.data.as_bytes()).unwrap();
_stream.flush().unwrap();
thread::spawn(move || {
// TODO: manage error case
_stream.write(response.data.as_bytes()).unwrap();
_stream.flush().unwrap();
});
}
}
}