~int80h/gemserv

077357e0d950460d9bb143c0e09d288141bd1ddb — int 80h 2 months ago 76a5dab
Fixed clean shutdown
3 files changed, 7 insertions(+), 3 deletions(-)

M Cargo.lock
M Cargo.toml
M src/conn.rs
M Cargo.lock => Cargo.lock +1 -1
@@ 140,7 140,7 @@ dependencies = [

[[package]]
name = "gemserv"
version = "0.4.6"
version = "0.4.7"
dependencies = [
 "futures-util",
 "log",

M Cargo.toml => Cargo.toml +1 -1
@@ 1,6 1,6 @@
[package]
name = "gemserv"
version = "0.4.6"
version = "0.4.7"
authors = ["int 80h <int@80h.dev>"]
edition = "2018"
description = "A gemini server"

M src/conn.rs => src/conn.rs +5 -1
@@ 4,7 4,7 @@ use std::net::SocketAddr;

use tokio::net::TcpStream;
use tokio::io::AsyncRead;
use tokio::io::AsyncWriteExt;
use tokio::io::{AsyncWrite, AsyncWriteExt};
use tokio_openssl::SslStream;

use crate::status::Status;


@@ 35,6 35,9 @@ impl Connection {
        if let Some(b) = body {
            self.send_raw(b.as_bytes()).await?;
        }

        futures_util::future::poll_fn(|ctx| std::pin::Pin::new(&mut self.stream).poll_shutdown(ctx)).await.unwrap();

        Ok(())
    }



@@ 46,6 49,7 @@ impl Connection {

    pub async fn send_stream<S: AsyncRead + Unpin>(&mut self, reader: &mut S) -> Result<(), io::Error> {
        tokio::io::copy(reader, &mut self.stream).await?;
        futures_util::future::poll_fn(|ctx| std::pin::Pin::new(&mut self.stream).poll_shutdown(ctx)).await.unwrap();
        Ok(())
    }
}