Http responses contain body

This commit is contained in:
2021-05-16 12:23:34 +02:00
parent a8c6962b20
commit 782ad13e48
7 changed files with 175 additions and 30 deletions

17
src/websocket/mod.rs Normal file
View File

@ -0,0 +1,17 @@
use crate::http;
pub fn connection_handler(client: &mut http::HttpStream, req: &http::Request) {
client.server_keep_alive = false;
let mut res = http::Response::new();
if let http::Method::GET = req.method {
res.status(501);
} else {
res.status(405);
res.add_header("Allow", "GET");
res.send(&mut client.stream);
return;
}
res.send(&mut client.stream);
}