mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-28 01:52:57 +01:00
update actix-service
This commit is contained in:
parent
3a456ec148
commit
ce0b172598
13
Cargo.toml
13
Cargo.toml
@ -37,10 +37,14 @@ session = ["cookie/secure"]
|
||||
ssl = ["openssl", "actix-connector/ssl"]
|
||||
|
||||
[dependencies]
|
||||
actix-service = "0.3.2"
|
||||
#actix-service = "0.3.2"
|
||||
actix-codec = "0.1.0"
|
||||
actix-connector = "0.3.0"
|
||||
actix-utils = "0.3.1"
|
||||
#actix-connector = "0.3.0"
|
||||
#actix-utils = "0.3.1"
|
||||
|
||||
actix-connector = { git="https://github.com/actix/actix-net.git" }
|
||||
actix-service = { git="https://github.com/actix/actix-net.git" }
|
||||
actix-utils = { git="https://github.com/actix/actix-net.git" }
|
||||
|
||||
base64 = "0.10"
|
||||
backtrace = "0.3"
|
||||
@ -80,7 +84,8 @@ openssl = { version="0.10", optional = true }
|
||||
actix-rt = "0.1.0"
|
||||
#actix-server = { version = "0.3.0", features=["ssl"] }
|
||||
actix-server = { git="https://github.com/actix/actix-net.git", features=["ssl"] }
|
||||
actix-connector = { version = "0.3.0", features=["ssl"] }
|
||||
#actix-connector = { version = "0.3.0", features=["ssl"] }
|
||||
actix-connector = { git="https://github.com/actix/actix-net.git", features=["ssl"] }
|
||||
actix-http-test = { path="test-server", features=["ssl"] }
|
||||
env_logger = "0.6"
|
||||
serde_derive = "1.0"
|
||||
|
@ -133,11 +133,8 @@ impl Connector {
|
||||
/// Finish configuration process and create connector service.
|
||||
pub fn service(
|
||||
self,
|
||||
) -> impl Service<
|
||||
Request = Connect,
|
||||
Response = impl Connection,
|
||||
Error = ConnectorError,
|
||||
> + Clone {
|
||||
) -> impl Service<Connect, Response = impl Connection, Error = ConnectorError> + Clone
|
||||
{
|
||||
#[cfg(not(feature = "ssl"))]
|
||||
{
|
||||
let connector = TimeoutService::new(
|
||||
@ -314,12 +311,12 @@ mod connect_impl {
|
||||
Io1: AsyncRead + AsyncWrite + 'static,
|
||||
Io2: AsyncRead + AsyncWrite + 'static,
|
||||
T1: Service<
|
||||
Request = Connect,
|
||||
Connect,
|
||||
Response = (Connect, Io1, Protocol),
|
||||
Error = ConnectorError,
|
||||
>,
|
||||
T2: Service<
|
||||
Request = Connect,
|
||||
Connect,
|
||||
Response = (Connect, Io2, Protocol),
|
||||
Error = ConnectorError,
|
||||
>,
|
||||
@ -333,12 +330,12 @@ mod connect_impl {
|
||||
Io1: AsyncRead + AsyncWrite + 'static,
|
||||
Io2: AsyncRead + AsyncWrite + 'static,
|
||||
T1: Service<
|
||||
Request = Connect,
|
||||
Connect,
|
||||
Response = (Connect, Io1, Protocol),
|
||||
Error = ConnectorError,
|
||||
> + Clone,
|
||||
T2: Service<
|
||||
Request = Connect,
|
||||
Connect,
|
||||
Response = (Connect, Io2, Protocol),
|
||||
Error = ConnectorError,
|
||||
> + Clone,
|
||||
@ -351,22 +348,21 @@ mod connect_impl {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T1, T2, Io1, Io2> Service for InnerConnector<T1, T2, Io1, Io2>
|
||||
impl<T1, T2, Io1, Io2> Service<Connect> for InnerConnector<T1, T2, Io1, Io2>
|
||||
where
|
||||
Io1: AsyncRead + AsyncWrite + 'static,
|
||||
Io2: AsyncRead + AsyncWrite + 'static,
|
||||
T1: Service<
|
||||
Request = Connect,
|
||||
Connect,
|
||||
Response = (Connect, Io1, Protocol),
|
||||
Error = ConnectorError,
|
||||
>,
|
||||
T2: Service<
|
||||
Request = Connect,
|
||||
Connect,
|
||||
Response = (Connect, Io2, Protocol),
|
||||
Error = ConnectorError,
|
||||
>,
|
||||
{
|
||||
type Request = Connect;
|
||||
type Response = EitherConnection<Io1, Io2>;
|
||||
type Error = ConnectorError;
|
||||
type Future = Either<
|
||||
@ -401,23 +397,15 @@ mod connect_impl {
|
||||
pub(crate) struct InnerConnectorResponseA<T, Io1, Io2>
|
||||
where
|
||||
Io1: AsyncRead + AsyncWrite + 'static,
|
||||
T: Service<
|
||||
Request = Connect,
|
||||
Response = (Connect, Io1, Protocol),
|
||||
Error = ConnectorError,
|
||||
>,
|
||||
T: Service<Connect, Response = (Connect, Io1, Protocol), Error = ConnectorError>,
|
||||
{
|
||||
fut: <ConnectionPool<T, Io1> as Service>::Future,
|
||||
fut: <ConnectionPool<T, Io1> as Service<Connect>>::Future,
|
||||
_t: PhantomData<Io2>,
|
||||
}
|
||||
|
||||
impl<T, Io1, Io2> Future for InnerConnectorResponseA<T, Io1, Io2>
|
||||
where
|
||||
T: Service<
|
||||
Request = Connect,
|
||||
Response = (Connect, Io1, Protocol),
|
||||
Error = ConnectorError,
|
||||
>,
|
||||
T: Service<Connect, Response = (Connect, Io1, Protocol), Error = ConnectorError>,
|
||||
Io1: AsyncRead + AsyncWrite + 'static,
|
||||
Io2: AsyncRead + AsyncWrite + 'static,
|
||||
{
|
||||
@ -435,23 +423,15 @@ mod connect_impl {
|
||||
pub(crate) struct InnerConnectorResponseB<T, Io1, Io2>
|
||||
where
|
||||
Io2: AsyncRead + AsyncWrite + 'static,
|
||||
T: Service<
|
||||
Request = Connect,
|
||||
Response = (Connect, Io2, Protocol),
|
||||
Error = ConnectorError,
|
||||
>,
|
||||
T: Service<Connect, Response = (Connect, Io2, Protocol), Error = ConnectorError>,
|
||||
{
|
||||
fut: <ConnectionPool<T, Io2> as Service>::Future,
|
||||
fut: <ConnectionPool<T, Io2> as Service<Connect>>::Future,
|
||||
_t: PhantomData<Io1>,
|
||||
}
|
||||
|
||||
impl<T, Io1, Io2> Future for InnerConnectorResponseB<T, Io1, Io2>
|
||||
where
|
||||
T: Service<
|
||||
Request = Connect,
|
||||
Response = (Connect, Io2, Protocol),
|
||||
Error = ConnectorError,
|
||||
>,
|
||||
T: Service<Connect, Response = (Connect, Io2, Protocol), Error = ConnectorError>,
|
||||
Io1: AsyncRead + AsyncWrite + 'static,
|
||||
Io2: AsyncRead + AsyncWrite + 'static,
|
||||
{
|
||||
|
@ -48,11 +48,7 @@ pub(crate) struct ConnectionPool<T, Io: AsyncRead + AsyncWrite + 'static>(
|
||||
impl<T, Io> ConnectionPool<T, Io>
|
||||
where
|
||||
Io: AsyncRead + AsyncWrite + 'static,
|
||||
T: Service<
|
||||
Request = Connect,
|
||||
Response = (Connect, Io, Protocol),
|
||||
Error = ConnectorError,
|
||||
>,
|
||||
T: Service<Connect, Response = (Connect, Io, Protocol), Error = ConnectorError>,
|
||||
{
|
||||
pub(crate) fn new(
|
||||
connector: T,
|
||||
@ -88,16 +84,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, Io> Service for ConnectionPool<T, Io>
|
||||
impl<T, Io> Service<Connect> for ConnectionPool<T, Io>
|
||||
where
|
||||
Io: AsyncRead + AsyncWrite + 'static,
|
||||
T: Service<
|
||||
Request = Connect,
|
||||
Response = (Connect, Io, Protocol),
|
||||
Error = ConnectorError,
|
||||
>,
|
||||
T: Service<Connect, Response = (Connect, Io, Protocol), Error = ConnectorError>,
|
||||
{
|
||||
type Request = Connect;
|
||||
type Response = IoConnection<Io>;
|
||||
type Error = ConnectorError;
|
||||
type Future = Either<
|
||||
|
@ -176,7 +176,7 @@ where
|
||||
) -> impl Future<Item = ClientResponse, Error = SendRequestError>
|
||||
where
|
||||
B: 'static,
|
||||
T: Service<Request = Connect, Response = I, Error = ConnectorError>,
|
||||
T: Service<Connect, Response = I, Error = ConnectorError>,
|
||||
I: Connection,
|
||||
{
|
||||
let Self { head, body } = self;
|
||||
|
@ -36,14 +36,14 @@ bitflags! {
|
||||
}
|
||||
|
||||
/// Dispatcher for HTTP/1.1 protocol
|
||||
pub struct Dispatcher<T, S: Service + 'static, B: MessageBody>
|
||||
pub struct Dispatcher<T, S: Service<Request> + 'static, B: MessageBody>
|
||||
where
|
||||
S::Error: Debug,
|
||||
{
|
||||
inner: Option<InnerDispatcher<T, S, B>>,
|
||||
}
|
||||
|
||||
struct InnerDispatcher<T, S: Service + 'static, B: MessageBody>
|
||||
struct InnerDispatcher<T, S: Service<Request> + 'static, B: MessageBody>
|
||||
where
|
||||
S::Error: Debug,
|
||||
{
|
||||
@ -67,13 +67,13 @@ enum DispatcherMessage {
|
||||
Error(Response<()>),
|
||||
}
|
||||
|
||||
enum State<S: Service, B: MessageBody> {
|
||||
enum State<S: Service<Request>, B: MessageBody> {
|
||||
None,
|
||||
ServiceCall(S::Future),
|
||||
SendPayload(ResponseBody<B>),
|
||||
}
|
||||
|
||||
impl<S: Service, B: MessageBody> State<S, B> {
|
||||
impl<S: Service<Request>, B: MessageBody> State<S, B> {
|
||||
fn is_empty(&self) -> bool {
|
||||
if let State::None = self {
|
||||
true
|
||||
@ -86,7 +86,7 @@ impl<S: Service, B: MessageBody> State<S, B> {
|
||||
impl<T, S, B> Dispatcher<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request = Request> + 'static,
|
||||
S: Service<Request> + 'static,
|
||||
S::Error: Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody,
|
||||
@ -141,7 +141,7 @@ where
|
||||
impl<T, S, B> InnerDispatcher<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request = Request> + 'static,
|
||||
S: Service<Request> + 'static,
|
||||
S::Error: Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody,
|
||||
@ -464,7 +464,7 @@ where
|
||||
impl<T, S, B> Future for Dispatcher<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request = Request>,
|
||||
S: Service<Request>,
|
||||
S::Error: Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody,
|
||||
|
@ -28,14 +28,14 @@ pub struct H1Service<T, S, B> {
|
||||
|
||||
impl<T, S, B> H1Service<T, S, B>
|
||||
where
|
||||
S: NewService<Request = Request>,
|
||||
S: NewService<Request>,
|
||||
S::Error: Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
S::Service: 'static,
|
||||
B: MessageBody,
|
||||
{
|
||||
/// Create new `HttpService` instance with default config.
|
||||
pub fn new<F: IntoNewService<S>>(service: F) -> Self {
|
||||
pub fn new<F: IntoNewService<S, Request>>(service: F) -> Self {
|
||||
let cfg = ServiceConfig::new(KeepAlive::Timeout(5), 5000, 0);
|
||||
|
||||
H1Service {
|
||||
@ -46,7 +46,10 @@ where
|
||||
}
|
||||
|
||||
/// Create new `HttpService` instance with config.
|
||||
pub fn with_config<F: IntoNewService<S>>(cfg: ServiceConfig, service: F) -> Self {
|
||||
pub fn with_config<F: IntoNewService<S, Request>>(
|
||||
cfg: ServiceConfig,
|
||||
service: F,
|
||||
) -> Self {
|
||||
H1Service {
|
||||
cfg,
|
||||
srv: service.into_new_service(),
|
||||
@ -60,16 +63,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S, B> NewService for H1Service<T, S, B>
|
||||
impl<T, S, B> NewService<T> for H1Service<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: NewService<Request = Request>,
|
||||
S: NewService<Request>,
|
||||
S::Error: Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
S::Service: 'static,
|
||||
B: MessageBody,
|
||||
{
|
||||
type Request = T;
|
||||
type Response = H1ServiceResult<T>;
|
||||
type Error = DispatchError<S::Error>;
|
||||
type InitError = S::InitError;
|
||||
@ -101,7 +103,7 @@ pub struct H1ServiceBuilder<T, S> {
|
||||
|
||||
impl<T, S> H1ServiceBuilder<T, S>
|
||||
where
|
||||
S: NewService<Request = Request>,
|
||||
S: NewService<Request>,
|
||||
S::Error: Debug,
|
||||
{
|
||||
/// Create instance of `ServiceConfigBuilder`
|
||||
@ -199,7 +201,7 @@ where
|
||||
pub fn finish<F, B>(self, service: F) -> H1Service<T, S, B>
|
||||
where
|
||||
B: MessageBody,
|
||||
F: IntoNewService<S>,
|
||||
F: IntoNewService<S, Request>,
|
||||
{
|
||||
let cfg = ServiceConfig::new(
|
||||
self.keep_alive,
|
||||
@ -215,7 +217,7 @@ where
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub struct H1ServiceResponse<T, S: NewService, B> {
|
||||
pub struct H1ServiceResponse<T, S: NewService<Request>, B> {
|
||||
fut: <S::Future as IntoFuture>::Future,
|
||||
cfg: Option<ServiceConfig>,
|
||||
_t: PhantomData<(T, B)>,
|
||||
@ -224,7 +226,7 @@ pub struct H1ServiceResponse<T, S: NewService, B> {
|
||||
impl<T, S, B> Future for H1ServiceResponse<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: NewService<Request = Request>,
|
||||
S: NewService<Request>,
|
||||
S::Service: 'static,
|
||||
S::Error: Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
@ -251,7 +253,7 @@ pub struct H1ServiceHandler<T, S: 'static, B> {
|
||||
|
||||
impl<T, S, B> H1ServiceHandler<T, S, B>
|
||||
where
|
||||
S: Service<Request = Request>,
|
||||
S: Service<Request>,
|
||||
S::Error: Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody,
|
||||
@ -265,15 +267,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S, B> Service for H1ServiceHandler<T, S, B>
|
||||
impl<T, S, B> Service<T> for H1ServiceHandler<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request = Request>,
|
||||
S: Service<Request>,
|
||||
S::Error: Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody,
|
||||
{
|
||||
type Request = T;
|
||||
type Response = H1ServiceResult<T>;
|
||||
type Error = DispatchError<S::Error>;
|
||||
type Future = Dispatcher<T, S, B>;
|
||||
@ -307,11 +308,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> NewService for OneRequest<T>
|
||||
impl<T> NewService<T> for OneRequest<T>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
{
|
||||
type Request = T;
|
||||
type Response = (Request, Framed<T, Codec>);
|
||||
type Error = ParseError;
|
||||
type InitError = ();
|
||||
@ -333,11 +333,10 @@ pub struct OneRequestService<T> {
|
||||
_t: PhantomData<T>,
|
||||
}
|
||||
|
||||
impl<T> Service for OneRequestService<T>
|
||||
impl<T> Service<T> for OneRequestService<T>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
{
|
||||
type Request = T;
|
||||
type Response = (Request, Framed<T, Codec>);
|
||||
type Error = ParseError;
|
||||
type Future = OneRequestServiceResponse<T>;
|
||||
|
@ -38,7 +38,11 @@ bitflags! {
|
||||
}
|
||||
|
||||
/// Dispatcher for HTTP/2 protocol
|
||||
pub struct Dispatcher<T: AsyncRead + AsyncWrite, S: Service + 'static, B: MessageBody> {
|
||||
pub struct Dispatcher<
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request<Payload>> + 'static,
|
||||
B: MessageBody,
|
||||
> {
|
||||
flags: Flags,
|
||||
service: CloneableService<S>,
|
||||
connection: Connection<T, Bytes>,
|
||||
@ -51,7 +55,7 @@ pub struct Dispatcher<T: AsyncRead + AsyncWrite, S: Service + 'static, B: Messag
|
||||
impl<T, S, B> Dispatcher<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request = Request<Payload>> + 'static,
|
||||
S: Service<Request<Payload>> + 'static,
|
||||
S::Error: Into<Error> + fmt::Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody + 'static,
|
||||
@ -93,7 +97,7 @@ where
|
||||
impl<T, S, B> Future for Dispatcher<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request = Request<Payload>> + 'static,
|
||||
S: Service<Request<Payload>> + 'static,
|
||||
S::Error: Into<Error> + fmt::Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody + 'static,
|
||||
@ -139,20 +143,20 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
struct ServiceResponse<S: Service, B> {
|
||||
struct ServiceResponse<S: Service<Request<Payload>>, B> {
|
||||
state: ServiceResponseState<S, B>,
|
||||
config: ServiceConfig,
|
||||
buffer: Option<Bytes>,
|
||||
}
|
||||
|
||||
enum ServiceResponseState<S: Service, B> {
|
||||
enum ServiceResponseState<S: Service<Request<Payload>>, B> {
|
||||
ServiceCall(S::Future, Option<SendResponse<Bytes>>),
|
||||
SendPayload(SendStream<Bytes>, ResponseBody<B>),
|
||||
}
|
||||
|
||||
impl<S, B> ServiceResponse<S, B>
|
||||
where
|
||||
S: Service<Request = Request<Payload>> + 'static,
|
||||
S: Service<Request<Payload>> + 'static,
|
||||
S::Error: Into<Error> + fmt::Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody + 'static,
|
||||
@ -220,7 +224,7 @@ where
|
||||
|
||||
impl<S, B> Future for ServiceResponse<S, B>
|
||||
where
|
||||
S: Service<Request = Request<Payload>> + 'static,
|
||||
S: Service<Request<Payload>> + 'static,
|
||||
S::Error: Into<Error> + fmt::Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody + 'static,
|
||||
|
@ -31,14 +31,14 @@ pub struct H2Service<T, S, B> {
|
||||
|
||||
impl<T, S, B> H2Service<T, S, B>
|
||||
where
|
||||
S: NewService<Request = Request<Payload>>,
|
||||
S: NewService<Request<Payload>>,
|
||||
S::Service: 'static,
|
||||
S::Error: Into<Error> + Debug + 'static,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody + 'static,
|
||||
{
|
||||
/// Create new `HttpService` instance.
|
||||
pub fn new<F: IntoNewService<S>>(service: F) -> Self {
|
||||
pub fn new<F: IntoNewService<S, Request<Payload>>>(service: F) -> Self {
|
||||
let cfg = ServiceConfig::new(KeepAlive::Timeout(5), 5000, 0);
|
||||
|
||||
H2Service {
|
||||
@ -54,16 +54,15 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S, B> NewService for H2Service<T, S, B>
|
||||
impl<T, S, B> NewService<T> for H2Service<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: NewService<Request = Request<Payload>>,
|
||||
S: NewService<Request<Payload>>,
|
||||
S::Service: 'static,
|
||||
S::Error: Into<Error> + Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody + 'static,
|
||||
{
|
||||
type Request = T;
|
||||
type Response = ();
|
||||
type Error = DispatchError<()>;
|
||||
type InitError = S::InitError;
|
||||
@ -95,7 +94,7 @@ pub struct H2ServiceBuilder<T, S> {
|
||||
|
||||
impl<T, S> H2ServiceBuilder<T, S>
|
||||
where
|
||||
S: NewService<Request = Request<Payload>>,
|
||||
S: NewService<Request<Payload>>,
|
||||
S::Service: 'static,
|
||||
S::Error: Into<Error> + Debug + 'static,
|
||||
{
|
||||
@ -213,7 +212,7 @@ where
|
||||
pub fn finish<F, B>(self, service: F) -> H2Service<T, S, B>
|
||||
where
|
||||
B: MessageBody,
|
||||
F: IntoNewService<S>,
|
||||
F: IntoNewService<S, Request<Payload>>,
|
||||
{
|
||||
let cfg = ServiceConfig::new(
|
||||
self.keep_alive,
|
||||
@ -229,7 +228,7 @@ where
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
pub struct H2ServiceResponse<T, S: NewService, B> {
|
||||
pub struct H2ServiceResponse<T, S: NewService<Request<Payload>>, B> {
|
||||
fut: <S::Future as IntoFuture>::Future,
|
||||
cfg: Option<ServiceConfig>,
|
||||
_t: PhantomData<(T, B)>,
|
||||
@ -238,7 +237,7 @@ pub struct H2ServiceResponse<T, S: NewService, B> {
|
||||
impl<T, S, B> Future for H2ServiceResponse<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: NewService<Request = Request<Payload>>,
|
||||
S: NewService<Request<Payload>>,
|
||||
S::Service: 'static,
|
||||
S::Response: Into<Response<B>>,
|
||||
S::Error: Into<Error> + Debug,
|
||||
@ -265,7 +264,7 @@ pub struct H2ServiceHandler<T, S: 'static, B> {
|
||||
|
||||
impl<T, S, B> H2ServiceHandler<T, S, B>
|
||||
where
|
||||
S: Service<Request = Request<Payload>> + 'static,
|
||||
S: Service<Request<Payload>> + 'static,
|
||||
S::Error: Into<Error> + Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody + 'static,
|
||||
@ -279,15 +278,14 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, S, B> Service for H2ServiceHandler<T, S, B>
|
||||
impl<T, S, B> Service<T> for H2ServiceHandler<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request = Request<Payload>> + 'static,
|
||||
S: Service<Request<Payload>> + 'static,
|
||||
S::Error: Into<Error> + Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody + 'static,
|
||||
{
|
||||
type Request = T;
|
||||
type Response = ();
|
||||
type Error = DispatchError<()>;
|
||||
type Future = H2ServiceHandlerResponse<T, S, B>;
|
||||
@ -310,7 +308,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
enum State<T: AsyncRead + AsyncWrite, S: Service + 'static, B: MessageBody> {
|
||||
enum State<
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request<Payload>> + 'static,
|
||||
B: MessageBody,
|
||||
> {
|
||||
Incoming(Dispatcher<T, S, B>),
|
||||
Handshake(
|
||||
Option<CloneableService<S>>,
|
||||
@ -322,7 +324,7 @@ enum State<T: AsyncRead + AsyncWrite, S: Service + 'static, B: MessageBody> {
|
||||
pub struct H2ServiceHandlerResponse<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request = Request<Payload>> + 'static,
|
||||
S: Service<Request<Payload>> + 'static,
|
||||
S::Error: Into<Error> + Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody + 'static,
|
||||
@ -333,7 +335,7 @@ where
|
||||
impl<T, S, B> Future for H2ServiceHandlerResponse<T, S, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request = Request<Payload>> + 'static,
|
||||
S: Service<Request<Payload>> + 'static,
|
||||
S::Error: Into<Error> + Debug,
|
||||
S::Response: Into<Response<B>>,
|
||||
B: MessageBody,
|
||||
|
@ -22,12 +22,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, R, E> NewService for SendError<T, R, E>
|
||||
impl<T, R, E> NewService<Result<R, (E, Framed<T, Codec>)>> for SendError<T, R, E>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
E: ResponseError,
|
||||
{
|
||||
type Request = Result<R, (E, Framed<T, Codec>)>;
|
||||
type Response = R;
|
||||
type Error = (E, Framed<T, Codec>);
|
||||
type InitError = ();
|
||||
@ -39,12 +38,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, R, E> Service for SendError<T, R, E>
|
||||
impl<T, R, E> Service<Result<R, (E, Framed<T, Codec>)>> for SendError<T, R, E>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
E: ResponseError,
|
||||
{
|
||||
type Request = Result<R, (E, Framed<T, Codec>)>;
|
||||
type Response = R;
|
||||
type Error = (E, Framed<T, Codec>);
|
||||
type Future = Either<FutureResult<R, (E, Framed<T, Codec>)>, SendErrorFut<T, R, E>>;
|
||||
@ -130,12 +128,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, B> NewService for SendResponse<T, B>
|
||||
impl<T, B> NewService<(Response<B>, Framed<T, Codec>)> for SendResponse<T, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
B: MessageBody,
|
||||
{
|
||||
type Request = (Response<B>, Framed<T, Codec>);
|
||||
type Response = Framed<T, Codec>;
|
||||
type Error = Error;
|
||||
type InitError = ();
|
||||
@ -147,12 +144,11 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T, B> Service for SendResponse<T, B>
|
||||
impl<T, B> Service<(Response<B>, Framed<T, Codec>)> for SendResponse<T, B>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
B: MessageBody,
|
||||
{
|
||||
type Request = (Response<B>, Framed<T, Codec>);
|
||||
type Response = Framed<T, Codec>;
|
||||
type Error = Error;
|
||||
type Future = SendResponseFut<T, B>;
|
||||
|
@ -26,7 +26,7 @@ pub type DefaultClient = Client<DefaultConnector>;
|
||||
/// WebSocket's client
|
||||
pub struct Client<T>
|
||||
where
|
||||
T: Service<Request = TcpConnect, Error = ConnectorError>,
|
||||
T: Service<TcpConnect, Error = ConnectorError>,
|
||||
T::Response: AsyncRead + AsyncWrite,
|
||||
{
|
||||
connector: T,
|
||||
@ -34,7 +34,7 @@ where
|
||||
|
||||
impl<T> Client<T>
|
||||
where
|
||||
T: Service<Request = TcpConnect, Error = ConnectorError>,
|
||||
T: Service<TcpConnect, Error = ConnectorError>,
|
||||
T::Response: AsyncRead + AsyncWrite,
|
||||
{
|
||||
/// Create new websocket's client factory
|
||||
@ -51,7 +51,7 @@ impl Default for Client<DefaultConnector> {
|
||||
|
||||
impl<T> Clone for Client<T>
|
||||
where
|
||||
T: Service<Request = TcpConnect, Error = ConnectorError> + Clone,
|
||||
T: Service<TcpConnect, Error = ConnectorError> + Clone,
|
||||
T::Response: AsyncRead + AsyncWrite,
|
||||
{
|
||||
fn clone(&self) -> Self {
|
||||
@ -61,13 +61,12 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Service for Client<T>
|
||||
impl<T> Service<Connect> for Client<T>
|
||||
where
|
||||
T: Service<Request = TcpConnect, Error = ConnectorError>,
|
||||
T: Service<TcpConnect, Error = ConnectorError>,
|
||||
T::Response: AsyncRead + AsyncWrite + 'static,
|
||||
T::Future: 'static,
|
||||
{
|
||||
type Request = Connect;
|
||||
type Response = Framed<T::Response, Codec>;
|
||||
type Error = ClientError;
|
||||
type Future = Either<
|
||||
|
@ -20,8 +20,7 @@ impl<T> Default for VerifyWebSockets<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> NewService for VerifyWebSockets<T> {
|
||||
type Request = (Request, Framed<T, Codec>);
|
||||
impl<T> NewService<(Request, Framed<T, Codec>)> for VerifyWebSockets<T> {
|
||||
type Response = (Request, Framed<T, Codec>);
|
||||
type Error = (HandshakeError, Framed<T, Codec>);
|
||||
type InitError = ();
|
||||
@ -33,8 +32,7 @@ impl<T> NewService for VerifyWebSockets<T> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Service for VerifyWebSockets<T> {
|
||||
type Request = (Request, Framed<T, Codec>);
|
||||
impl<T> Service<(Request, Framed<T, Codec>)> for VerifyWebSockets<T> {
|
||||
type Response = (Request, Framed<T, Codec>);
|
||||
type Error = (HandshakeError, Framed<T, Codec>);
|
||||
type Future = FutureResult<Self::Response, Self::Error>;
|
||||
|
@ -7,7 +7,7 @@ use super::{Codec, Frame, Message};
|
||||
|
||||
pub struct Transport<S, T>
|
||||
where
|
||||
S: Service<Request = Frame, Response = Message> + 'static,
|
||||
S: Service<Frame, Response = Message> + 'static,
|
||||
T: AsyncRead + AsyncWrite,
|
||||
{
|
||||
inner: FramedTransport<S, T, Codec>,
|
||||
@ -16,17 +16,17 @@ where
|
||||
impl<S, T> Transport<S, T>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request = Frame, Response = Message>,
|
||||
S: Service<Frame, Response = Message>,
|
||||
S::Future: 'static,
|
||||
S::Error: 'static,
|
||||
{
|
||||
pub fn new<F: IntoService<S>>(io: T, service: F) -> Self {
|
||||
pub fn new<F: IntoService<S, Frame>>(io: T, service: F) -> Self {
|
||||
Transport {
|
||||
inner: FramedTransport::new(Framed::new(io, Codec::new()), service),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with<F: IntoService<S>>(framed: Framed<T, Codec>, service: F) -> Self {
|
||||
pub fn with<F: IntoService<S, Frame>>(framed: Framed<T, Codec>, service: F) -> Self {
|
||||
Transport {
|
||||
inner: FramedTransport::new(framed, service),
|
||||
}
|
||||
@ -36,7 +36,7 @@ where
|
||||
impl<S, T> Future for Transport<S, T>
|
||||
where
|
||||
T: AsyncRead + AsyncWrite,
|
||||
S: Service<Request = Frame, Response = Message>,
|
||||
S: Service<Frame, Response = Message>,
|
||||
S::Future: 'static,
|
||||
S::Error: 'static,
|
||||
{
|
||||
|
@ -35,10 +35,12 @@ ssl = ["openssl", "actix-http/ssl", "actix-server/ssl"]
|
||||
actix-codec = "0.1"
|
||||
actix-rt = "0.1.0"
|
||||
actix-http = { path=".." }
|
||||
actix-service = "0.3.2"
|
||||
#actix-service = "0.3.2"
|
||||
actix-service = { git="https://github.com/actix/actix-net.git" }
|
||||
#actix-server = "0.3.0"
|
||||
actix-server = { git="https://github.com/actix/actix-net.git" }
|
||||
actix-utils = "0.3.2"
|
||||
#actix-utils = "0.3.2"
|
||||
actix-utils = { git="https://github.com/actix/actix-net.git" }
|
||||
|
||||
base64 = "0.10"
|
||||
bytes = "0.4"
|
||||
|
@ -56,8 +56,7 @@ impl TestServer {
|
||||
pub fn new<F: StreamServiceFactory>(
|
||||
factory: F,
|
||||
) -> TestServerRuntime<
|
||||
impl Service<Request = Connect, Response = impl Connection, Error = ConnectorError>
|
||||
+ Clone,
|
||||
impl Service<Connect, Response = impl Connection, Error = ConnectorError> + Clone,
|
||||
> {
|
||||
let (tx, rx) = mpsc::channel();
|
||||
|
||||
@ -89,11 +88,8 @@ impl TestServer {
|
||||
}
|
||||
|
||||
fn new_connector(
|
||||
) -> impl Service<
|
||||
Request = Connect,
|
||||
Response = impl Connection,
|
||||
Error = ConnectorError,
|
||||
> + Clone {
|
||||
) -> impl Service<Connect, Response = impl Connection, Error = ConnectorError> + Clone
|
||||
{
|
||||
#[cfg(feature = "ssl")]
|
||||
{
|
||||
use openssl::ssl::{SslConnector, SslMethod, SslVerifyMode};
|
||||
@ -206,7 +202,7 @@ impl<T> TestServerRuntime<T> {
|
||||
|
||||
impl<T> TestServerRuntime<T>
|
||||
where
|
||||
T: Service<Request = Connect, Error = ConnectorError> + Clone,
|
||||
T: Service<Connect, Error = ConnectorError> + Clone,
|
||||
T::Response: Connection,
|
||||
{
|
||||
/// Connect to websocket server at a given path
|
||||
|
Loading…
Reference in New Issue
Block a user