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