commit bf09e83d53f2059e961939d6a323a8de57b017cd
parent a0c20258cb027df98c6995507eb25f20ec594fc4
Author: Matt Brubeck <mbrubeck@limpet.net>
Date: Sun, 17 May 2020 10:39:30 -0700
Minor changes
Diffstat:
1 file changed, 17 insertions(+), 11 deletions(-)
diff --git a/src/main.rs b/src/main.rs
@@ -18,17 +18,6 @@ use {
pub type Result<T=()> = std::result::Result<T, Box<dyn Error>>;
-async fn connection(acceptor: TlsAcceptor, stream: TcpStream) -> io::Result<()> {
- let stream = acceptor.accept(stream).await?;
- let mut stream = async_std::io::BufReader::new(stream);
- let mut body = String::new();
- stream.read_line(&mut body).await?;
- let mut stream = stream.into_inner();
- stream.write_all(b"20 text/plain\r\n").await?;
- stream.write_all(body.as_bytes()).await?;
- Ok(())
-}
-
fn main() -> Result {
env_logger::init();
@@ -60,3 +49,20 @@ fn main() -> Result {
Ok(())
})
}
+
+async fn connection(acceptor: TlsAcceptor, stream: TcpStream) -> io::Result<()> {
+ let stream = acceptor.accept(stream).await?;
+
+ let mut stream = async_std::io::BufReader::new(stream);
+ let mut body = String::new();
+ stream.read_line(&mut body).await?;
+ eprintln!("Got request: {:?}", body);
+
+ let mut stream = stream.into_inner();
+ stream.write_all(b"20 text/plain\r\n").await?;
+ stream.write_all(b"=> ").await?;
+ stream.write_all(body.trim().as_bytes()).await?;
+ stream.write_all(b" Go to ").await?;
+ stream.write_all(body.as_bytes()).await?;
+ Ok(())
+}