start of http stuff

This commit is contained in:
Luuk van Oijen
2023-11-15 13:38:07 +01:00
parent 51c5ee0638
commit 8735824495
2 changed files with 32 additions and 0 deletions

14
src/server/http.rs Normal file
View File

@@ -0,0 +1,14 @@
use tokio::io::{AsyncReadExt, AsyncWriteExt};
use tokio::net::{
tcp::{OwnedReadHalf, OwnedWriteHalf},
TcpStream,
};
pub async fn handle_http_get(socket: TcpStream) {
let (read_half, write_half) = socket.into_split();
todo!()
}
async fn read_get_request(socket: &mut OwnedReadHalf) {
todo!()
}

View File

@@ -16,12 +16,14 @@ mod car;
mod client;
mod packet;
mod plugins;
mod http;
pub use backend::*;
pub use car::*;
pub use client::*;
pub use packet::*;
pub use plugins::*;
pub use http::*;
pub use crate::config::Config;
@@ -171,6 +173,22 @@ impl Server {
}
}
},
'D' => {
// Download connection (for old protocol)
// New protocol should use HTTP for downloads, so
// I will leave this unimplemented for now.
},
'G' => {
// This is probably an HTTP GET request!
let mut tmp = [0u8; 3];
socket.read_exact(&mut tmp).await.expect("Failed to read from socket!");
if tmp[0] as char == 'E' && tmp[1] as char == 'T' && tmp[2] as char == ' ' {
trace!("HTTP GET request found!");
handle_http_get(socket).await;
} else {
trace!("Unknown G packet received, not sure what to do!");
}
},
_ => {},
};
});