mirror of https://github.com/fafhrd91/actix-web
Merge branch 'master' into refactor/h1_dispatcher_poll_keepalive
This commit is contained in:
commit
60c0958220
|
@ -4,11 +4,16 @@
|
||||||
### Fixed
|
### Fixed
|
||||||
* Double ampersand in Logger format is escaped correctly. [#2067]
|
* Double ampersand in Logger format is escaped correctly. [#2067]
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
* `CustomResponder` would return error as `HttpResponse` when `CustomResponder::with_header` failed instead of skipping.
|
||||||
|
(Only the first error is kept when multiple error occur) [#2093]
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
* The `client` mod was removed. Clients should now use `awc` directly.
|
* The `client` mod was removed. Clients should now use `awc` directly.
|
||||||
[871ca5e4](https://github.com/actix/actix-web/commit/871ca5e4ae2bdc22d1ea02701c2992fa8d04aed7)
|
[871ca5e4](https://github.com/actix/actix-web/commit/871ca5e4ae2bdc22d1ea02701c2992fa8d04aed7)
|
||||||
|
|
||||||
[#2067]: https://github.com/actix/actix-web/pull/2067
|
[#2067]: https://github.com/actix/actix-web/pull/2067
|
||||||
|
[#2093]: https://github.com/actix/actix-web/pull/2093
|
||||||
|
|
||||||
|
|
||||||
## 4.0.0-beta.4 - 2021-03-09
|
## 4.0.0-beta.4 - 2021-03-09
|
||||||
|
|
|
@ -105,7 +105,7 @@ serde = { version = "1.0", features = ["derive"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
serde_urlencoded = "0.7"
|
serde_urlencoded = "0.7"
|
||||||
smallvec = "1.6"
|
smallvec = "1.6"
|
||||||
socket2 = "0.3.16"
|
socket2 = "0.4.0"
|
||||||
time = { version = "0.2.23", default-features = false, features = ["std"] }
|
time = { version = "0.2.23", default-features = false, features = ["std"] }
|
||||||
tls-openssl = { package = "openssl", version = "0.10.9", optional = true }
|
tls-openssl = { package = "openssl", version = "0.10.9", optional = true }
|
||||||
tls-rustls = { package = "rustls", version = "0.19.0", optional = true }
|
tls-rustls = { package = "rustls", version = "0.19.0", optional = true }
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use std::{fmt, io, path::PathBuf, rc::Rc, task::Poll};
|
use std::{fmt, io, path::PathBuf, rc::Rc};
|
||||||
|
|
||||||
use actix_service::Service;
|
use actix_service::Service;
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
|
|
|
@ -42,7 +42,7 @@ bytes = "1"
|
||||||
futures-core = { version = "0.3.7", default-features = false }
|
futures-core = { version = "0.3.7", default-features = false }
|
||||||
http = "0.2.2"
|
http = "0.2.2"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
socket2 = "0.3"
|
socket2 = "0.4"
|
||||||
serde = "1.0"
|
serde = "1.0"
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
slab = "0.4"
|
slab = "0.4"
|
||||||
|
|
|
@ -118,10 +118,10 @@ pub async fn test_server_with_addr<F: ServiceFactory<TcpStream>>(
|
||||||
/// Get first available unused address
|
/// Get first available unused address
|
||||||
pub fn unused_addr() -> net::SocketAddr {
|
pub fn unused_addr() -> net::SocketAddr {
|
||||||
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
||||||
let socket = Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
|
let socket = Socket::new(Domain::IPV4, Type::STREAM, Some(Protocol::TCP)).unwrap();
|
||||||
socket.bind(&addr.into()).unwrap();
|
socket.bind(&addr.into()).unwrap();
|
||||||
socket.set_reuse_address(true).unwrap();
|
socket.set_reuse_address(true).unwrap();
|
||||||
let tcp = socket.into_tcp_listener();
|
let tcp = net::TcpListener::from(socket);
|
||||||
tcp.local_addr().unwrap()
|
tcp.local_addr().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,7 +325,7 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const H2_UNREACHABLE_WRITE: &'static str = "H2Connection can not impl AsyncWrite trait";
|
const H2_UNREACHABLE_WRITE: &str = "H2Connection can not impl AsyncWrite trait";
|
||||||
|
|
||||||
impl<A, B> AsyncWrite for Connection<A, B>
|
impl<A, B> AsyncWrite for Connection<A, B>
|
||||||
where
|
where
|
||||||
|
|
|
@ -126,9 +126,7 @@ impl ServiceConfig {
|
||||||
pub fn client_timer(&self) -> Option<Sleep> {
|
pub fn client_timer(&self) -> Option<Sleep> {
|
||||||
let delay_time = self.0.client_timeout;
|
let delay_time = self.0.client_timeout;
|
||||||
if delay_time != 0 {
|
if delay_time != 0 {
|
||||||
Some(sleep_until(
|
Some(sleep_until(self.now() + Duration::from_millis(delay_time)))
|
||||||
self.0.date_service.now() + Duration::from_millis(delay_time),
|
|
||||||
))
|
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -138,7 +136,7 @@ impl ServiceConfig {
|
||||||
pub fn client_timer_expire(&self) -> Option<Instant> {
|
pub fn client_timer_expire(&self) -> Option<Instant> {
|
||||||
let delay = self.0.client_timeout;
|
let delay = self.0.client_timeout;
|
||||||
if delay != 0 {
|
if delay != 0 {
|
||||||
Some(self.0.date_service.now() + Duration::from_millis(delay))
|
Some(self.now() + Duration::from_millis(delay))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -148,7 +146,7 @@ impl ServiceConfig {
|
||||||
pub fn client_disconnect_timer(&self) -> Option<Instant> {
|
pub fn client_disconnect_timer(&self) -> Option<Instant> {
|
||||||
let delay = self.0.client_disconnect;
|
let delay = self.0.client_disconnect;
|
||||||
if delay != 0 {
|
if delay != 0 {
|
||||||
Some(self.0.date_service.now() + Duration::from_millis(delay))
|
Some(self.now() + Duration::from_millis(delay))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -157,20 +155,12 @@ impl ServiceConfig {
|
||||||
#[inline]
|
#[inline]
|
||||||
/// Return keep-alive timer delay is configured.
|
/// Return keep-alive timer delay is configured.
|
||||||
pub fn keep_alive_timer(&self) -> Option<Sleep> {
|
pub fn keep_alive_timer(&self) -> Option<Sleep> {
|
||||||
if let Some(ka) = self.0.keep_alive {
|
self.keep_alive().map(|ka| sleep_until(self.now() + ka))
|
||||||
Some(sleep_until(self.0.date_service.now() + ka))
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Keep-alive expire time
|
/// Keep-alive expire time
|
||||||
pub fn keep_alive_expire(&self) -> Option<Instant> {
|
pub fn keep_alive_expire(&self) -> Option<Instant> {
|
||||||
if let Some(ka) = self.0.keep_alive {
|
self.keep_alive().map(|ka| self.now() + ka)
|
||||||
Some(self.0.date_service.now() + ka)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
|
@ -127,9 +127,8 @@ impl Display for EntityTag {
|
||||||
impl FromStr for EntityTag {
|
impl FromStr for EntityTag {
|
||||||
type Err = crate::error::ParseError;
|
type Err = crate::error::ParseError;
|
||||||
|
|
||||||
fn from_str(s: &str) -> Result<EntityTag, crate::error::ParseError> {
|
fn from_str(slice: &str) -> Result<EntityTag, crate::error::ParseError> {
|
||||||
let length: usize = s.len();
|
let length = slice.len();
|
||||||
let slice = &s[..];
|
|
||||||
// Early exits if it doesn't terminate in a DQUOTE.
|
// Early exits if it doesn't terminate in a DQUOTE.
|
||||||
if !slice.ends_with('"') || slice.len() < 2 {
|
if !slice.ends_with('"') || slice.len() < 2 {
|
||||||
return Err(crate::error::ParseError::Header);
|
return Err(crate::error::ParseError::Header);
|
||||||
|
|
|
@ -88,9 +88,9 @@ pub fn parse_extended_value(
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(ExtendedValue {
|
Ok(ExtendedValue {
|
||||||
value,
|
|
||||||
charset,
|
charset,
|
||||||
language_tag,
|
language_tag,
|
||||||
|
value,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,7 +113,7 @@ pub struct AppConfig {
|
||||||
|
|
||||||
impl AppConfig {
|
impl AppConfig {
|
||||||
pub(crate) fn new(secure: bool, addr: SocketAddr, host: String) -> Self {
|
pub(crate) fn new(secure: bool, addr: SocketAddr, host: String) -> Self {
|
||||||
AppConfig { secure, addr, host }
|
AppConfig { secure, host, addr }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Server host name.
|
/// Server host name.
|
||||||
|
|
|
@ -28,17 +28,6 @@ where
|
||||||
fn call(&self, param: T) -> R;
|
fn call(&self, param: T) -> R;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<F, R> Handler<(), R> for F
|
|
||||||
where
|
|
||||||
F: Fn() -> R + Clone + 'static,
|
|
||||||
R: Future,
|
|
||||||
R::Output: Responder,
|
|
||||||
{
|
|
||||||
fn call(&self, _: ()) -> R {
|
|
||||||
(self)()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
/// Extract arguments from request, run factory function and make response.
|
/// Extract arguments from request, run factory function and make response.
|
||||||
pub struct HandlerService<F, T, R>
|
pub struct HandlerService<F, T, R>
|
||||||
|
@ -177,30 +166,29 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
/// FromRequest trait impl for tuples
|
/// FromRequest trait impl for tuples
|
||||||
macro_rules! factory_tuple ({ $(($n:tt, $T:ident)),+} => {
|
macro_rules! factory_tuple ({ $($param:ident)* } => {
|
||||||
impl<Func, $($T,)+ Res> Handler<($($T,)+), Res> for Func
|
impl<Func, $($param,)* Res> Handler<($($param,)*), Res> for Func
|
||||||
where Func: Fn($($T,)+) -> Res + Clone + 'static,
|
where Func: Fn($($param),*) -> Res + Clone + 'static,
|
||||||
Res: Future,
|
Res: Future,
|
||||||
Res::Output: Responder,
|
Res::Output: Responder,
|
||||||
{
|
{
|
||||||
fn call(&self, param: ($($T,)+)) -> Res {
|
#[allow(non_snake_case)]
|
||||||
(self)($(param.$n,)+)
|
fn call(&self, ($($param,)*): ($($param,)*)) -> Res {
|
||||||
|
(self)($($param,)*)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
#[rustfmt::skip]
|
factory_tuple! {}
|
||||||
mod m {
|
factory_tuple! { A }
|
||||||
use super::*;
|
factory_tuple! { A B }
|
||||||
|
factory_tuple! { A B C }
|
||||||
factory_tuple!((0, A));
|
factory_tuple! { A B C D }
|
||||||
factory_tuple!((0, A), (1, B));
|
factory_tuple! { A B C D E }
|
||||||
factory_tuple!((0, A), (1, B), (2, C));
|
factory_tuple! { A B C D E F }
|
||||||
factory_tuple!((0, A), (1, B), (2, C), (3, D));
|
factory_tuple! { A B C D E F G }
|
||||||
factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E));
|
factory_tuple! { A B C D E F G H }
|
||||||
factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F));
|
factory_tuple! { A B C D E F G H I }
|
||||||
factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G));
|
factory_tuple! { A B C D E F G H I J }
|
||||||
factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H));
|
factory_tuple! { A B C D E F G H I J K }
|
||||||
factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H), (8, I));
|
factory_tuple! { A B C D E F G H I J K L }
|
||||||
factory_tuple!((0, A), (1, B), (2, C), (3, D), (4, E), (5, F), (6, G), (7, H), (8, I), (9, J));
|
|
||||||
}
|
|
||||||
|
|
12
src/lib.rs
12
src/lib.rs
|
@ -173,11 +173,7 @@ pub mod dev {
|
||||||
|
|
||||||
impl BodyEncoding for ResponseBuilder {
|
impl BodyEncoding for ResponseBuilder {
|
||||||
fn get_encoding(&self) -> Option<ContentEncoding> {
|
fn get_encoding(&self) -> Option<ContentEncoding> {
|
||||||
if let Some(ref enc) = self.extensions().get::<Enc>() {
|
self.extensions().get::<Enc>().map(|enc| enc.0)
|
||||||
Some(enc.0)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self {
|
fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self {
|
||||||
|
@ -188,11 +184,7 @@ pub mod dev {
|
||||||
|
|
||||||
impl<B> BodyEncoding for Response<B> {
|
impl<B> BodyEncoding for Response<B> {
|
||||||
fn get_encoding(&self) -> Option<ContentEncoding> {
|
fn get_encoding(&self) -> Option<ContentEncoding> {
|
||||||
if let Some(ref enc) = self.extensions().get::<Enc>() {
|
self.extensions().get::<Enc>().map(|enc| enc.0)
|
||||||
Some(enc.0)
|
|
||||||
} else {
|
|
||||||
None
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self {
|
fn encoding(&mut self, encoding: ContentEncoding) -> &mut Self {
|
||||||
|
|
|
@ -197,22 +197,23 @@ impl AcceptEncoding {
|
||||||
|
|
||||||
/// Parse a raw Accept-Encoding header value into an ordered list.
|
/// Parse a raw Accept-Encoding header value into an ordered list.
|
||||||
pub fn parse(raw: &str, encoding: ContentEncoding) -> ContentEncoding {
|
pub fn parse(raw: &str, encoding: ContentEncoding) -> ContentEncoding {
|
||||||
let mut encodings: Vec<_> = raw
|
let mut encodings = raw
|
||||||
.replace(' ', "")
|
.replace(' ', "")
|
||||||
.split(',')
|
.split(',')
|
||||||
.map(|l| AcceptEncoding::new(l))
|
.map(|l| AcceptEncoding::new(l))
|
||||||
.collect();
|
.flatten()
|
||||||
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
encodings.sort();
|
encodings.sort();
|
||||||
|
|
||||||
for enc in encodings {
|
for enc in encodings {
|
||||||
if let Some(enc) = enc {
|
|
||||||
if encoding == ContentEncoding::Auto {
|
if encoding == ContentEncoding::Auto {
|
||||||
return enc.encoding;
|
return enc.encoding;
|
||||||
} else if encoding == enc.encoding {
|
} else if encoding == enc.encoding {
|
||||||
return encoding;
|
return encoding;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
ContentEncoding::Identity
|
ContentEncoding::Identity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -449,9 +449,9 @@ impl ServiceFactory<ServiceRequest> for ResourceFactory {
|
||||||
.collect::<Result<Vec<_>, _>>()?;
|
.collect::<Result<Vec<_>, _>>()?;
|
||||||
|
|
||||||
Ok(ResourceService {
|
Ok(ResourceService {
|
||||||
|
routes,
|
||||||
app_data,
|
app_data,
|
||||||
default,
|
default,
|
||||||
routes,
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -155,8 +155,7 @@ impl Responder for BytesMut {
|
||||||
pub struct CustomResponder<T> {
|
pub struct CustomResponder<T> {
|
||||||
responder: T,
|
responder: T,
|
||||||
status: Option<StatusCode>,
|
status: Option<StatusCode>,
|
||||||
headers: Option<HeaderMap>,
|
headers: Result<HeaderMap, HttpError>,
|
||||||
error: Option<HttpError>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: Responder> CustomResponder<T> {
|
impl<T: Responder> CustomResponder<T> {
|
||||||
|
@ -164,8 +163,7 @@ impl<T: Responder> CustomResponder<T> {
|
||||||
CustomResponder {
|
CustomResponder {
|
||||||
responder,
|
responder,
|
||||||
status: None,
|
status: None,
|
||||||
headers: None,
|
headers: Ok(HeaderMap::new()),
|
||||||
error: None,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,14 +204,12 @@ impl<T: Responder> CustomResponder<T> {
|
||||||
where
|
where
|
||||||
H: IntoHeaderPair,
|
H: IntoHeaderPair,
|
||||||
{
|
{
|
||||||
if self.headers.is_none() {
|
if let Ok(ref mut headers) = self.headers {
|
||||||
self.headers = Some(HeaderMap::new());
|
|
||||||
}
|
|
||||||
|
|
||||||
match header.try_into_header_pair() {
|
match header.try_into_header_pair() {
|
||||||
Ok((key, value)) => self.headers.as_mut().unwrap().append(key, value),
|
Ok((key, value)) => headers.append(key, value),
|
||||||
Err(e) => self.error = Some(e.into()),
|
Err(e) => self.headers = Err(e.into()),
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
@ -221,17 +217,20 @@ impl<T: Responder> CustomResponder<T> {
|
||||||
|
|
||||||
impl<T: Responder> Responder for CustomResponder<T> {
|
impl<T: Responder> Responder for CustomResponder<T> {
|
||||||
fn respond_to(self, req: &HttpRequest) -> HttpResponse {
|
fn respond_to(self, req: &HttpRequest) -> HttpResponse {
|
||||||
|
let headers = match self.headers {
|
||||||
|
Ok(headers) => headers,
|
||||||
|
Err(err) => return HttpResponse::from_error(Error::from(err)),
|
||||||
|
};
|
||||||
|
|
||||||
let mut res = self.responder.respond_to(req);
|
let mut res = self.responder.respond_to(req);
|
||||||
|
|
||||||
if let Some(status) = self.status {
|
if let Some(status) = self.status {
|
||||||
*res.status_mut() = status;
|
*res.status_mut() = status;
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(ref headers) = self.headers {
|
|
||||||
for (k, v) in headers {
|
for (k, v) in headers {
|
||||||
// TODO: before v4, decide if this should be append instead
|
// TODO: before v4, decide if this should be append instead
|
||||||
res.headers_mut().insert(k.clone(), v.clone());
|
res.headers_mut().insert(k, v);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
res
|
res
|
||||||
|
|
|
@ -607,17 +607,14 @@ where
|
||||||
|
|
||||||
fn create_tcp_listener(addr: net::SocketAddr, backlog: u32) -> io::Result<net::TcpListener> {
|
fn create_tcp_listener(addr: net::SocketAddr, backlog: u32) -> io::Result<net::TcpListener> {
|
||||||
use socket2::{Domain, Protocol, Socket, Type};
|
use socket2::{Domain, Protocol, Socket, Type};
|
||||||
let domain = match addr {
|
let domain = Domain::for_address(addr);
|
||||||
net::SocketAddr::V4(_) => Domain::ipv4(),
|
let socket = Socket::new(domain, Type::STREAM, Some(Protocol::TCP))?;
|
||||||
net::SocketAddr::V6(_) => Domain::ipv6(),
|
|
||||||
};
|
|
||||||
let socket = Socket::new(domain, Type::stream(), Some(Protocol::tcp()))?;
|
|
||||||
socket.set_reuse_address(true)?;
|
socket.set_reuse_address(true)?;
|
||||||
socket.bind(&addr.into())?;
|
socket.bind(&addr.into())?;
|
||||||
// clamp backlog to max u32 that fits in i32 range
|
// clamp backlog to max u32 that fits in i32 range
|
||||||
let backlog = cmp::min(backlog, i32::MAX as u32) as i32;
|
let backlog = cmp::min(backlog, i32::MAX as u32) as i32;
|
||||||
socket.listen(backlog)?;
|
socket.listen(backlog)?;
|
||||||
Ok(socket.into_tcp_listener())
|
Ok(net::TcpListener::from(socket))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
|
|
|
@ -774,10 +774,10 @@ where
|
||||||
};
|
};
|
||||||
|
|
||||||
TestServer {
|
TestServer {
|
||||||
ssl,
|
|
||||||
addr,
|
addr,
|
||||||
client,
|
client,
|
||||||
system,
|
system,
|
||||||
|
ssl,
|
||||||
server,
|
server,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -862,10 +862,10 @@ impl TestServerConfig {
|
||||||
/// Get first available unused address
|
/// Get first available unused address
|
||||||
pub fn unused_addr() -> net::SocketAddr {
|
pub fn unused_addr() -> net::SocketAddr {
|
||||||
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
let addr: net::SocketAddr = "127.0.0.1:0".parse().unwrap();
|
||||||
let socket = Socket::new(Domain::ipv4(), Type::stream(), Some(Protocol::tcp())).unwrap();
|
let socket = Socket::new(Domain::IPV4, Type::STREAM, Some(Protocol::TCP)).unwrap();
|
||||||
socket.bind(&addr.into()).unwrap();
|
socket.bind(&addr.into()).unwrap();
|
||||||
socket.set_reuse_address(true).unwrap();
|
socket.set_reuse_address(true).unwrap();
|
||||||
let tcp = socket.into_tcp_listener();
|
let tcp = net::TcpListener::from(socket);
|
||||||
tcp.local_addr().unwrap()
|
tcp.local_addr().unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,15 +1,11 @@
|
||||||
use std::sync::mpsc;
|
|
||||||
use std::{thread, time::Duration};
|
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
extern crate tls_openssl as openssl;
|
extern crate tls_openssl as openssl;
|
||||||
#[cfg(feature = "rustls")]
|
|
||||||
extern crate tls_rustls as rustls;
|
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(any(unix, feature = "openssl"))]
|
||||||
use openssl::ssl::SslAcceptorBuilder;
|
use {
|
||||||
|
actix_web::{test, web, App, HttpResponse, HttpServer},
|
||||||
use actix_web::{test, web, App, HttpResponse, HttpServer};
|
std::{sync::mpsc, thread, time::Duration},
|
||||||
|
};
|
||||||
|
|
||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[actix_rt::test]
|
#[actix_rt::test]
|
||||||
|
@ -72,7 +68,7 @@ async fn test_start() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
fn ssl_acceptor() -> SslAcceptorBuilder {
|
fn ssl_acceptor() -> openssl::ssl::SslAcceptorBuilder {
|
||||||
use openssl::{
|
use openssl::{
|
||||||
pkey::PKey,
|
pkey::PKey,
|
||||||
ssl::{SslAcceptor, SslMethod},
|
ssl::{SslAcceptor, SslMethod},
|
||||||
|
|
Loading…
Reference in New Issue