1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 02:19:22 +02:00

sync with latest actix

This commit is contained in:
Nikolay Kim
2018-02-12 12:17:30 -08:00
parent 30bdf9cb5e
commit 8c1b5fa945
16 changed files with 65 additions and 103 deletions

View File

@ -5,7 +5,7 @@ use std::collections::VecDeque;
use std::time::Duration;
use actix::{fut, Actor, ActorFuture, Arbiter, Context,
Handler, Response, ResponseType, Supervised};
Handler, Message, ActorResponse, Supervised};
use actix::registry::ArbiterService;
use actix::fut::WrapFuture;
use actix::actors::{Connector, ConnectorError, Connect as ResolveConnect};
@ -37,9 +37,8 @@ impl Connect {
}
}
impl ResponseType for Connect {
type Item = Connection;
type Error = ClientConnectorError;
impl Message for Connect {
type Result = Result<Connection, ClientConnectorError>;
}
/// A set of errors that can occur during connecting to a http host
@ -163,34 +162,34 @@ impl ClientConnector {
}
impl Handler<Connect> for ClientConnector {
type Result = Response<ClientConnector, Connect>;
type Result = ActorResponse<ClientConnector, Connection, ClientConnectorError>;
fn handle(&mut self, msg: Connect, _: &mut Self::Context) -> Self::Result {
let uri = &msg.0;
// host name is required
if uri.host().is_none() {
return Response::reply(Err(ClientConnectorError::InvalidUrl))
return ActorResponse::reply(Err(ClientConnectorError::InvalidUrl))
}
// supported protocols
let proto = match uri.scheme_part() {
Some(scheme) => match Protocol::from(scheme.as_str()) {
Some(proto) => proto,
None => return Response::reply(Err(ClientConnectorError::InvalidUrl)),
None => return ActorResponse::reply(Err(ClientConnectorError::InvalidUrl)),
},
None => return Response::reply(Err(ClientConnectorError::InvalidUrl)),
None => return ActorResponse::reply(Err(ClientConnectorError::InvalidUrl)),
};
// check ssl availability
if proto.is_secure() && !HAS_OPENSSL { //&& !HAS_TLS {
return Response::reply(Err(ClientConnectorError::SslIsNotSupported))
return ActorResponse::reply(Err(ClientConnectorError::SslIsNotSupported))
}
let host = uri.host().unwrap().to_owned();
let port = uri.port().unwrap_or_else(|| proto.port());
Response::async_reply(
ActorResponse::async(
Connector::from_registry()
.call(self, ResolveConnect::host_and_port(&host, port))
.map_err(|_, _, _| ClientConnectorError::Disconnected)