mirror of
https://github.com/BeamMP/BeamMP-Server.git
synced 2026-04-04 23:06:08 +00:00
start of http stuff
This commit is contained in:
14
src/server/http.rs
Normal file
14
src/server/http.rs
Normal 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!()
|
||||
}
|
||||
@@ -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!");
|
||||
}
|
||||
},
|
||||
_ => {},
|
||||
};
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user