diff --git a/src/server/builder.rs b/src/server/builder.rs index 4a77bcd5..ad412444 100644 --- a/src/server/builder.rs +++ b/src/server/builder.rs @@ -98,6 +98,7 @@ where } } +/// This trait indicates types that can create acceptor service for http server. pub trait AcceptorServiceFactory: Send + Clone + 'static { type Io: IoStream + Send; type NewService: NewService< @@ -217,6 +218,7 @@ where } #[derive(Clone)] +/// Default acceptor service convert `TcpStream` to a `tokio_tcp::TcpStream` pub(crate) struct DefaultAcceptor; impl AcceptorServiceFactory for DefaultAcceptor { diff --git a/src/server/h1.rs b/src/server/h1.rs index 36d40e8d..b6b576ed 100644 --- a/src/server/h1.rs +++ b/src/server/h1.rs @@ -513,9 +513,7 @@ mod tests { use std::{cmp, io, time}; use bytes::{Buf, Bytes, BytesMut}; - use futures::future; use http::{Method, Version}; - use tokio::runtime::current_thread; use tokio_io::{AsyncRead, AsyncWrite}; use super::*; diff --git a/src/server/http.rs b/src/server/http.rs index f54900fc..3baf8a23 100644 --- a/src/server/http.rs +++ b/src/server/http.rs @@ -268,6 +268,7 @@ where mut self, lst: net::TcpListener, builder: SslAcceptorBuilder, ) -> io::Result { use super::{openssl_acceptor_with_flags, ServerFlags}; + use actix_net::service::NewServiceExt; let flags = if self.no_http2 { ServerFlags::HTTP1 @@ -283,6 +284,7 @@ where addr, scheme: "https", handler: Box::new(HttpServiceBuilder::new( + self.factory.clone(), move || ssl::OpensslAcceptor::new(acceptor.clone()).map_err(|_| ()), DefaultPipelineFactory::new( self.factory.clone(), @@ -411,6 +413,7 @@ where S: net::ToSocketAddrs, { use super::{openssl_acceptor_with_flags, ServerFlags}; + use actix_net::service::NewServiceExt; let sockets = self.bind2(addr)?; @@ -431,6 +434,7 @@ where addr, scheme: "https", handler: Box::new(HttpServiceBuilder::new( + self.factory.clone(), move || ssl::OpensslAcceptor::new(accpt.clone()).map_err(|_| ()), DefaultPipelineFactory::new( self.factory.clone(),