mirror of
https://github.com/actix/actix-web.git
synced 2024-12-21 23:56:35 +00:00
add Connector helper method
This commit is contained in:
parent
f9b9031af2
commit
71d725d250
2 changed files with 7 additions and 7 deletions
|
@ -2,7 +2,7 @@ use std::collections::VecDeque;
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::net::SocketAddr;
|
use std::net::SocketAddr;
|
||||||
|
|
||||||
use futures::{Async, Future, Poll, future::ok};
|
use futures::{future::ok, Async, Future, Poll};
|
||||||
use tokio;
|
use tokio;
|
||||||
use tokio_tcp::{ConnectFuture, TcpStream};
|
use tokio_tcp::{ConnectFuture, TcpStream};
|
||||||
use tower_service::Service;
|
use tower_service::Service;
|
||||||
|
@ -48,7 +48,7 @@ impl Connector {
|
||||||
Connector { resolver }
|
Connector { resolver }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new_service<E>() -> impl Future<Item=Connector, Error=E> {
|
pub fn new_service<E>() -> impl Future<Item = Connector, Error = E> {
|
||||||
ok(Connector::new())
|
ok(Connector::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
use std::io;
|
use std::io;
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
|
|
||||||
use futures::{future, future::FutureResult, Async, Poll, Future};
|
use futures::{future, future::FutureResult, Async, Future, Poll};
|
||||||
use openssl::ssl::{AlpnError, Error, SslAcceptor, SslAcceptorBuilder, SslConnector};
|
use openssl::ssl::{AlpnError, Error, SslAcceptor, SslAcceptorBuilder, SslConnector};
|
||||||
use tokio_io::{AsyncRead, AsyncWrite};
|
use tokio_io::{AsyncRead, AsyncWrite};
|
||||||
use tokio_openssl::{AcceptAsync, ConnectAsync, SslAcceptorExt, SslConnectorExt, SslStream};
|
use tokio_openssl::{AcceptAsync, ConnectAsync, SslAcceptorExt, SslConnectorExt, SslStream};
|
||||||
|
@ -146,9 +146,9 @@ impl<T: AsyncRead + AsyncWrite> Service for OpensslConnectorService<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn call(&mut self, (host, stream): Self::Request) -> Self::Future {
|
fn call(&mut self, (host, stream): Self::Request) -> Self::Future {
|
||||||
ConnectAsyncExt {
|
ConnectAsyncExt {
|
||||||
fut: SslConnectorExt::connect_async(&self.connector, &host, stream),
|
fut: SslConnectorExt::connect_async(&self.connector, &host, stream),
|
||||||
host: Some(host)
|
host: Some(host),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +168,7 @@ where
|
||||||
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
|
||||||
match self.fut.poll()? {
|
match self.fut.poll()? {
|
||||||
Async::Ready(stream) => Ok(Async::Ready((self.host.take().unwrap(), stream))),
|
Async::Ready(stream) => Ok(Async::Ready((self.host.take().unwrap(), stream))),
|
||||||
Async::NotReady => Ok(Async::NotReady)
|
Async::NotReady => Ok(Async::NotReady),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue