From 5ff6987a07fd2923115ef8974b55b8802ff35de2 Mon Sep 17 00:00:00 2001 From: "Christoph J. Scherr" Date: Wed, 24 Jan 2024 10:56:55 +0100 Subject: [PATCH] mini https --- src/server/mod.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/server/mod.rs b/src/server/mod.rs index d1e7498..8041533 100644 --- a/src/server/mod.rs +++ b/src/server/mod.rs @@ -73,7 +73,7 @@ impl Server { let (stream, addr) = match rc_self.server.accept().await { Ok(s) => s, Err(err) => { - warn!("could not accept stream: {err:?}"); + warn!("could not accept tcp stream: {err:?}"); continue; } }; @@ -86,7 +86,7 @@ impl Server { match ref_self.acceptor.accept(stream).await { Ok(s) => s, Err(err) => { - error!("could not accept tcp stream: {err}"); + warn!("could not accept tls stream: {err}"); return; } }; @@ -150,12 +150,20 @@ impl Server { addr: SocketAddr, ) -> Result<()> { debug!("new peer: {:?}", addr); - let mut buf = [0; BUF_SIZE]; - while stream.read(&mut buf).await? != 0 { - stream.write_all(b"pong\0"); - + loop { + stream + .write_all( + &b"HTTP/1.0 200 ok\r\n\ + Connection: close\r\n\ + Content-length: 12\r\n\ + \r\n\ + Hello world!"[..], + ) + .await?; + stream.flush().await?; // we should wait, so that we don't spam the client std::thread::sleep(self.cfg.delay); + break; } debug!("disconnected peer: {:?}", addr); Ok(())